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 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    35
    Thanks
    6
    Thanked 0 Times in 0 Posts

    PHP MySQL leaderboard

    I have two MySQL tables, one table stores all the members and one stores goals and who scored them etc. When someone reports a score on my league site and they enter statistics it inserts goals into the goals table. I am trying to code a script which gets the top 5 goal scorers from the table. How would I go about doing this?

    Any help would be appreciated
    Thanks.

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,509
    Thanks
    74
    Thanked 105 Times in 104 Posts
    PHP Code:
    $query mysql_query("SELECT * FROM goalstable WHERE goals > '0' ORDER BY goals DESC LIMIT 5");

    while (
    $row mysql_fetch_array($query)) {
    echo 
    "".$row['goals']."<br />

    Something to that nature, it will show the top 5, starting with the highest goals.

  • Users who have thanked myfayt for this post:

    mrkfc (09-06-2011)

  • #3
    New Coder
    Join Date
    Aug 2010
    Posts
    35
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thank you.

  • #4
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to code a script for a leaderboard for my site too. Having trouble. Cant figure out how to post a new thread...


  •  

    Posting Permissions

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