Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default PHP help, displaying SQL results

    Howdy. Basically this is annoying me now... I'm making a leader board. It uses a mysql query to get the top 10 highest scores and then display them in a table... I'm stuck at displaying them all.

    I can get the first one, but the rest are the same as the first... I've looked on google but I can't find it... it needs to loop or whatever, but I'm not too sure how.

    PHP Code:
    $get mysql_query("SELECT * FROM `users` ORDER BY `cash` DESC LIMIT 0 , 10 ");
        
    $get mysql_fetch_array($get);
        echo 
    "<table width=\"200\" border=\"1\">
     <tr>
        <td>"
    .$get['username']."</td>
        <td>"
    .$get['cash']."</td>
      </tr>
    </table>"

    If somebody could post a code so that it could loop it and display all 10 I'd be grateful.

    Thanks.

  2. #2
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    PHP Code:
    $get mysql_query("SELECT * FROM `users` ORDER BY `cash` DESC LIMIT 0,10");

    echo 
    '<table width="200" border="1">';

    while(
    $row mysql_fetch_array($get)) {
        echo 
    '<tr>';
        echo 
    '<td>' $row["username"] . '</td>';
        echo 
    '<td>' $row["cash"] . '</td>';
        echo 
    '</tr>';
    }

    echo 
    '</table>'
    Should work, I did it in text edit so it may.

  3. #3
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    I love you Caleb. Works perfectly, thanks ever so much!

Posting Permissions

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