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
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.
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(); ?>
0 Prince* Posted October 24, 2011 Posted October 24, 2011 Just search on forum :) http://maxcheaters.com/forum/index.php?topic=209698.msg1908727#msg1908727
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/
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?
0 WhiteDevil Posted October 25, 2011 Author Posted October 25, 2011 can someone give me the script??? <?PHP ..... >?
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
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.
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
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now