Description: Making your site say how many people are playing on your server.
Difficulty: 1/10
Assumed Knowledge: Your SQL server info. Basic Database knowledge.
Tested Server: Any SQL based server
Files/Classes Modified: online.php
You start off with remembering yourself of your SQL server Host, Username(probably 'root') and Password.
Also you should know what field in your database tells if a player is logged on.
On a Dodian/Devias/Devolution (SQL) server it would be field 'online' in table 'uber3_players'.
If you have any other source with SQL, look for something like loggedon or online or anything like that.
now Take a look at this code:
Code:
<?php
$connection = mysql_connect('HOST','USER','PASSWORD');
mysql_select_db('DATABASE', $connection);
$query = mysql_query('SELECT * FROM uber3_players WHERE online > 0');
$rows = mysql_num_rows($query);
if($rows == 0){
$playersOnline = "0 players online";
} elseif($rows == 1){
$playersOnline = "1 player online";
} elseif($rows > 1){
$playersOnline = $rows." players online";
} else {
$playersOnline = "Error occured";
}
?>
Create a new PHP file named 'online.php' with the code above in it.
change the following values:
HOST = your server host.
USER = SQL server username (probably root)
PASS = SQL server password
DATABASE = The database you used for your Server.
------------------------------------------------------
Now as you can see i used a Dodian server for example.
I bolded out the uber3_players and online because that part shows what to change if you have another database.
in my case what it does is:
SELECT * (select everything)
FROM uber3_players (from table uber3_players in the database we specified before)
WHERE online > 0 (where online is bigger then 0. My server sets that value to 1 if a player is logged in 1 minute, but this script also works if your server doesnt set the minutes, but just sets online (1) of offline (0) .)
So now it has selected all players wich have their online field set to 1.
The php script counts the rows, and knows how many players are logged in on your server.
It attaches it to a string named "$playersOnline".
Next thing is including and echoing the string out.
-------------------------------------------------------
Now to make your website show how many players are logged in you need a little piece of PHP script:
Code:
<?php
include ("online.php");
echo "$playersOnline"; ?>
*Please notice*
If the PHP file 'online.php' isn't in the same directory as the script in which you are going to include this script, you need to change the URL to your location of 'online.php'
Upload all the files to your webserver, and this should work like a charm.
If you have any question please post 
Thats all.
Thanks very much for reading my tutorial.
I hope it helped.