sql >> Database teknologi >  >> RDS >> Mysql

bestil efter XXX sorter efter ASC eller DESC, dynamisk bestilling, mysql...

<?php

    $order = ($_GET['order'] == 'asc') ? 'asc' : 'desc';

    $sql = "SELECT .... FROM ... WHERE ... ORDER BY TITLE $order";
    mysql_query($sql) or die(mysql_error());
    ...

     $new_order = ($order == 'asc' ) ? 'desc' : 'asc';
?>

<table>
<thead><tr>
    <th><a href="scriptname.php?order=<?php echo $new_order ?>">TITLE</a></th>
    <th>Total</th>
</tr></thead>
etc....


  1. Enkel måde at transponere kolonner og rækker i SQL?

  2. DBTIMEZONE-funktion i Oracle

  3. Liste alle tabeller i postgresql informationsskema

  4. psycopg2.OperationalError:FATAL:ikke-understøttet frontend-protokol 1234.5679:server understøtter 2.0 til 3.0