WhiteDevil Posted October 24, 2011 Posted October 24, 2011 How do I make a script to display on my website how many players there are online? To display on my site for example: Players Online: 120 Quote
0 dpbBryan Posted October 24, 2011 Posted October 24, 2011 connect to your mysql database, then: SELECT char_name (or whatever properties you need) FROM characters WHERE online = 1; Then count em. Quote
0 dpbBryan Posted October 24, 2011 Posted October 24, 2011 -.- ..... all script? This is what your code should look like: <?php $mysql_connect = ( "ip_of_server", "mysql_user", "mysql_password" ); $mysql_select = mysql_select_db( "name_of_l2j_db" ); $player_query = mysql_query( "SELECT char_name FROM characters WHERE online = 1" ); $player_count = mysql_num_rows( $player_query ); echo $player_count; $mysql_connect.close(); ?> Quote
0 Prince* Posted October 24, 2011 Posted October 24, 2011 Just search on forum :) http://maxcheaters.com/forum/index.php?topic=209698.msg1908727#msg1908727 Quote
0 WhiteDevil Posted October 25, 2011 Author Posted October 25, 2011 Just search on forum :) http://maxcheaters.com/forum/index.php?topic=209698.msg1908727#msg1908727 i want to add it on main page...see 1 site that count players.. http://l2renaissance.com/ Quote
0 dpbBryan Posted October 25, 2011 Posted October 25, 2011 i want to add it on main page...see 1 site that count players.. http://l2renaissance.com/ I pretty much gave you what you need, have you ever worked with PHP/MySQL or anything related to web development before? Quote
0 WhiteDevil Posted October 25, 2011 Author Posted October 25, 2011 can someone give me the script??? <?PHP ..... >? Quote
0 dpbBryan Posted October 25, 2011 Posted October 25, 2011 can someone give me the script??? <?PHP ..... >? Are you blind or just straight up retarded? http://maxcheaters.com/forum/index.php?topic=223719.msg1960564#msg1960564 Quote
0 Simmo Posted October 25, 2011 Posted October 25, 2011 <? $host = "127.0.0.1"; $username = "root"; $password = "root"; $db_name = "l2jdb"; function connect_db() { mysql_connect("$host", "$username", "$password")or die("Can't connect to the database."); } function select_db() { mysql_select_db("$db_name")or die("Can't select the database."); } //query variables $field = "char_name"; $table = "characters"; $value = "1"; $rule = "online"; connect_db(); select_db(); $query = mysql_real_escape_string(mysql_query("SELECT $field FROM $table WHERE $rule = $value")); $count = mysql_num_rows($query); echo "Players online: "$count"."; ?> Haven't tested it, as it doesn't save the result to a file and just display the file I advise not using it on a server that's going to have a lot of traffic going to the website. But as you've asked for this, i doubt you plan on that anyway. Quote
Question
WhiteDevil
How do I make a script to display on my website how many players there are online?
To display on my site for example:
Players Online: 120
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.