Jump to content

Display highest value from database question


Ashikaa

Recommended Posts

Try this (not tested):

 

$result = mysql_query("SELECT * FROM table_name ORDER BY Score LIMIT 3");

while($row = mysql_fetch_array($result))
{
//HTML formatting (tables etc...)
  echo $row['ID'] . " " . $row['Name'] . " " . $row['Score'];
  echo "
";
}

you could change your SQL statement to look like this

 

$result = mysql_query("SELECT * FROM table_name ORDER BY Score DESC LIMIT 3");

 

The DESC sorts the query from the last record to the first... now this is only a quick fix as long as your biggest record is the last record in the database

The DESC sorts the query from the last record to the first... now this is only a quick fix as long as your biggest record is the last record in the database

 

Incorrect. ORDER BY `columnName` DESC will order by that column name in descending order ( z-a.. highest to lowest... ect )

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.