Page 1 of 1
Reversing the order of the 'ORDER BY' statement
Posted: Mon Nov 10, 2008 4:49 pm
by oscardog
Code: Select all
$result = mysql_query("SELECT * FROM guilds ORDER BY '$server', '$filter', gname");
echo "<table width=\"175\">";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<th scope=\"row\">" . $row['gname'] . "</th>";
echo "<td>" . $row[$filter] . "</td>";
echo "</tr>";
}
echo "</table>";
Now it doesnt matter what it throws out, but there are 4 servers. From a drop down list, it gathers what server and what filter(xp, level, total members or average level). But with that code, say they choose level, the lowest level appears at the top, how do i reverse it so that the highest appears at the top/first?
Thanks!
Re: Reversing the order of the 'ORDER BY' statement
Posted: Mon Nov 10, 2008 4:53 pm
by requinix
Code: Select all
...ORDER BY field1 [ASC | DESC] [, field2 [ASC | DESC] [, field3 [ASC | DESC] ] ]
That's ASCending and DESCending.
If you don't give one, the default is ASC.
As VladSun says below, [] indicates something optional. You aren't supposed to include them.
So each ASC/DESC above is optional and each additional field is optional.
Re: Reversing the order of the 'ORDER BY' statement
Posted: Mon Nov 10, 2008 4:58 pm
by oscardog
Thanks Alot!
Re: Reversing the order of the 'ORDER BY' statement
Posted: Mon Nov 10, 2008 5:02 pm
by oscardog
Code: Select all
$result = mysql_query("SELECT * FROM guilds ORDER BY '$server', '$filter' [ASC], gname");
Thats right? Doesn't display on the game anymore...
Re: Reversing the order of the 'ORDER BY' statement
Posted: Mon Nov 10, 2008 5:14 pm
by VladSun
[] in manuals means - "not required".
You should remove the square brackets from your query.