can't find the answer alone. I want to connect mySQL server and count the users online. After that, print it out as an number & draw picture bar according user number.
This is what I managed to pull.
<?PHP
//db info
define('mySQL_hostname', '192.0.0.1'); //database IP
define('mySQL_database', 'mywebdb'); //database name
define('mySQL_username', 'root'); //database user
define('mySQL_password', 's1mpl3'); //database password
//connects to mysql
$db_link = mysql_pconnect( mySQL_hostname, mySQL_username, mySQL_password )
or die( 'Error connecting to mysql<br><br>'.mysql_error() );
//connects to Database
$db_select = mysql_select_db( mySQL_database, $db_link )
or die( 'Error connecting to Database<br><br>'.mysql_error() );
//selects desired table
$chars= mysql_query("SELECT `online` FROM `users` where `online`=1");
$rows = mysql_num_rows($chars);
echo "<b><em>".$rows."<em></b>"; //prints out the $x number of players online
?>
What i want to do with this... to make ~150px brown bar and put some green pixels for each user online. Example 50 users = 100%. 0 users = 1% I did a css file inside PHP and managed to draw brown bar.
#bar_empty {
background-color: #401800;
width: 150px;
height: 6px;
}
So "echo ""; now gives a brown bar to work on, but i have no idea how to set bar "worth of the pixel" and how print them out. Any ideas would be great.