Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Quantity Rating

  1. #1
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Quantity Rating

    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.

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

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Use a MySQL query to get the rows:
    Code:
    SELECT * FROM `table` WHERE 1 ORDER BY `quantity` DESC LIMIT 10
    And just for reference, that code above is the same as this:
    PHP Code:
    for($i 1$i <= 10$i++)
        echo 
    $i '<br />';
    echo 
    '<br />'


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •