Visualizzazione dei risultati da 1 a 5 su 5

Discussione: risultati select

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    892

    risultati select

    Scusate,
    sapete come fare per ordinare in senso decrescente i risultati di una estrazione da db?

  2. #2
    select * from table where..... order by campo desc

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    1,056
    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

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    892

    non funziona...

    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é?

  5. #5
    LIMIT deve essere l'ultimo dei parametri della select.


    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.