...

View Full Version : Quantity Rating



Cerby
11-15-2007, 07:01 PM
I have a field in the database called "Quantity". How do I find the 10 most highest numbers, then display them on a rating of 1-10. 1being the highest, and 10 being the lowest.

The following code creates the numbers 1-10.


for ($i = '1'; ; $i++)
{
echo $i . '<br>';
if ($i == "10")
{
echo '<br><br>';
break;
}
}

Inigoesdr
11-15-2007, 07:27 PM
Use a MySQL query to get the rows:

SELECT * FROM `table` WHERE 1 ORDER BY `quantity` DESC LIMIT 10

And just for reference, that code above is the same as this:

for($i = 1; $i <= 10; $i++)
echo $i . '<br />';
echo '<br />';



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum