Jump to content

PHP + MySQL Leaderboard System


Carbon

Recommended Posts

Hi, I am trying to create a php + mysql leaderboard systems and I am very new to php + mysql so I'm asking for help here :)

 

I have a program and I want to upload stats from that program to the mysql database which will then create a highscores page.

 

I currently have made a dynamic image for this, I only have 1 entry in the database, it can be found here: http://autowatch.net23.net/autowatch/highscores/img/image.php?user=testuser

 

The code I am using to generate that image is:

<?php
// MySQL Setting
$db_host = "removed";
$db_user = "removed";
$db_pass = "removed";
$db_data = "removed";

// Image
mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_data);
$Qry = mysql_query("SELECT * FROM highscores WHERE Username='$_GET[user]'");
while($Dt = mysql_fetch_array($Qry)) {
header("Content-Type: image/png");
$Image = ImageCreateFromPng('images/design3.png');
$User = $Dt['Username'];
$TimeRan = $Dt['Time'];
$Field1 = $Dt['Videos'];
$Field2 = $Dt['Credits'];
$Color = ImageColorAllocate($Image, 224, 191, 142);
ImageString($Image, 2, 48, 58, $User, $Color);
ImageString($Image, 2, 68, 95, $TimeRan, $Color);
ImageString($Image, 2, 63, 135, "Coming Soon...", $Color);
ImageString($Image, 2, 309, 58, $Field1, $Color);
ImageString($Image, 2, 314, 95, $Field2, $Color);
ImagePng($Image);
ImageDestroy($Image);
}
?>

 

Now my question is, if I had mutiple entries into the database (which will happen soon) how can I go about creating a highscores page which would rank users based on who has the highest videos field and then in the dynamic image how can I display the position of that user in the highscores? And also how would I go about updating each field using PHP? (i can then use that in the program so they are automatically updated)

 

Sorry if I haven't explained this that well, if you need anything else then please just say!

 

Thanks,

Carbon

Link to comment
https://forums.phpfreaks.com/topic/245010-php-mysql-leaderboard-system/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.