Skip to content

PHP - Script Players Online for WebSite

Featured Replies

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

 

connect to your mysql database, then:

SELECT char_name (or whatever properties you need) FROM characters WHERE online = 1;

Then count em.

  • Author

-.- ..... all script?

-.- ..... 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();
?>

youknow that sql can count too?

  • Author

 

i want to add it on main page...see 1 site that count players..

http://l2renaissance.com/

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?

  • Author

can someone give me the script???

<?PHP

.....

>?

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

<?

$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.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.