Scusate,
sapete come fare per ordinare in senso decrescente i risultati di una estrazione da db?
Scusate,
sapete come fare per ordinare in senso decrescente i risultati di una estrazione da db?
select * from table where..... order by campo desc
dal manuale di mysql
Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column names, column aliases, or column positions. Column positions are integers and begin with 1:
mysql> SELECT college, region, seed FROM tournament
-> ORDER BY region, seed;
mysql> SELECT college, region AS r, seed AS s FROM tournament
-> ORDER BY r, s;
mysql> SELECT college, region, seed FROM tournament
-> ORDER BY 2, 3;
To sort in reverse order, add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword. Use of column positions is deprecated because the syntax has been removed from the SQL standard.
Quindi dovrebbe essere SELECT * FROM tabella ORDER BY campo DESC
Scusate, ma (senz'altro per colpa mia...) non funziona.
Questo è il codice dell'estrazione:
$query_limit = mysql_query("SELECT numero, DATE_FORMAT(giorno,'%d/%m/%Y') as data FROM determinazioni LIMIT $primo, $per_page ORDER BY numero DESC");
while($results = mysql_fetch_array($query_limit)) {
echo " <tr>\n <td>";
echo "<a href=\"page.php?numero=" . $results['numero'] . "\">" . $results['numero'] . "</a>
" . $results['data'] . "
";
echo "</td>\n </tr>\n";
}
E questo è l'errore che mi dà:
Warning: Supplied argument is not a valid MySQL result resource in /var/www/cossal/public/paginazione.php on line 32
Qualcuno sa dirmi perché?
LIMIT deve essere l'ultimo dei parametri della select.
![]()
Il silenzio è spesso la cosa migliore. Pensa ... è gratis.