Creating MySQL leaderboard

1.7k Views Asked by At

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?

2

There are 2 best solutions below

0
On

To answer your question about how do you make the website, like @MrJack said, you need to make a server, and possibly get a domain name. I wrote a page that walks one through the gist of making a server and buying domains. It can be found here. (I'm currently updating the guide as I haven't for a while, so it might change in 10 minutes.)

Full disclosure: As I mentioned, I made this page. I get no money from ads on it, it's just for educating people interested in servers.

MrJack's answer covers the rest of your questions, and I don't need to repeat them.

0
On

How do I succesfully link that php file into a webpage?

Host it on a php server, buy an address and point it to your server. You can test everything on localhost by installing your own LAMP or WAMP.

how do i make a decent webpage of it.

Programmers make for terrible site designers, this is not the place for that. We can help you with how to make a line pink or yellow, but not where to put it so it fits in your design.

In college, my teacher basically translated that site for our Web course. It's not the best way to do things, but it's great for getting to know the basics and learning. http://www.w3schools.com/

I don't know if this code is right, thats why I came posting here.

Neither do I, that's why you should create your own localhost webserver and test it, but it looks wrong. You should use PDO or ADOdb for queries since mysql_query is deprecated (meaning it will stop working in newer versions).

http://www.wampserver.com/en/ for Windows

http://www.linux.com/learn/tutorials/288158-easy-lamp-server-installation for linux