Wednesday, 28 August 2013

Creating MySQL leaderboard

Creating MySQL leaderboard

I'm quite new to programming and certainly to anything that is website
related. I'm 16 years old, so don't make it too complicated :)
I'm trying to make a leaderboard made out of MySQL data. The MySQL data
comes from a plugin on a minecraft server. So I linked the plugin's data
to a MySQL database, called iConomy
In the database I made 2 tables atm: iconomy and bitcoin
The meaning is that a leaderboard would be displayed on the website as:
Rank Number | Username | Bitcoin | Balance
1. |Nicolas | xxxxxxx | 1500
So 1 would be the rank number, Nicolas my username, bitcoin my bitcoin
adress. And balance my current money in game. That data gets provided by
the plugin that I succesfully linked into the MySQL database that I
mentioned.
Reading through a few posts and copying a bit of code, I came to this php
code:
<?php
$result = mysql_query("SELECT username, balance, adress FROM iconomy,
bitcoin ORDER BY balance DESC");
$rank = 1;
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_assoc($result)) {
echo "<td>{$rank}</td>
<td>{$row['username']}</td>
<td>{$row['balance']}</td>
<td>{$row['adress']}</td>";
$rank++;
}
}
?>
So as you can see i have the username, balance, adress which i get from
the tables iconomy and bitcoin (thats where the adresses would be stored).
I don't know if this code is right, thats why I came posting here.
But if it is (this will sound stupid), how do i make a decent webpage of it.
How do I succesfully link that php file into a webpage?
Thanks in advance!

No comments:

Post a Comment