View Full Version : PHP MySQL leaderboard

09-05-2011, 04:10 PM
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 :)

09-05-2011, 07:16 PM
$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.

09-06-2011, 08:40 PM
Thank you.

09-14-2011, 08:28 PM
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...