ORDER BY
Posted: Fri Jul 01, 2005 7:15 am
hi, i got the following code but the order by claus isnt ordering it...
what this returns is:
Username: Cost:
hagrg 97952
sdjhe 4779
qfhdf 300000
rggrg 130059
as you can see the cost isnt in decreasing order like it should be.. (300000, 130059, 97952, 4779)
any help appriciated...
Code: Select all
$result = mysql_query("SELECT cost, username FROM table ORDER BY cost DESC LIMIT 4") or die(mysql_error());
echo '<table border="1" align="center">';
echo '<tr><td width="500" height="15" colspan="2" align="center"><strong>Result</strong></td></tr>';
echo '<tr><td width="400" height="15" align="left">Username:</td><td width="100" height="15" align="left">Cost:</td></tr>';
while($row = mysql_fetch_array($result))
{
echo '<tr><td width="400" height="15">'; echo $row[1];
echo '</td><td width="100" height="15">'; echo $row[0];
echo '</td></tr>';
}Username: Cost:
hagrg 97952
sdjhe 4779
qfhdf 300000
rggrg 130059
as you can see the cost isnt in decreasing order like it should be.. (300000, 130059, 97952, 4779)
any help appriciated...