Page 1 of 1
Requesting some ASB scripts.
#1
Posted 08 April 2004 - 12:07 AM
Anyone got a script that shows how many registered accounts there are and how many players are on currently? Thanks
#6
Posted 20 April 2004 - 10:32 PM
From the top of my head, try these code samples. Not sure if the database structure is 100% correct, but it should be relatively easy to fix.
Number of registered accounts:
Number of online players:
Number of registered accounts:
Quote
<?php
mssql_connect('localhost', 'login', 'tai');
mssql_select_db('nLogin');
$query = "SELECT * FROM login";
$result = mssql_query($query);
$accounts = mssql_num_rows($result);
echo "There are $accounts total accounts on the server.";
?>
mssql_connect('localhost', 'login', 'tai');
mssql_select_db('nLogin');
$query = "SELECT * FROM login";
$result = mssql_query($query);
$accounts = mssql_num_rows($result);
echo "There are $accounts total accounts on the server.";
?>
Number of online players:
Quote
<?php
mssql_connect('localhost', 'login', 'tai');
mssql_select_db(user);
$query = "SELECT * FROM t_user WHERE tu_state = '1'";
$result = mssql_query($query);
$online = mssql_num_rows($result);
echo "There are $online players online.";
?>
mssql_connect('localhost', 'login', 'tai');
mssql_select_db(user);
$query = "SELECT * FROM t_user WHERE tu_state = '1'";
$result = mssql_query($query);
$online = mssql_num_rows($result);
echo "There are $online players online.";
?>
#7
Posted 21 April 2004 - 05:38 AM
@Riotblade
Try this.
@azndragon
He requested ASP, not PHP scripts. ;) Also, concerning the sql you have.. could use just 'SELECT tu_state COUNT(1) FROM t_user' or 'SELECT * COUNT(*) FROM login'. Those I think would just throw back the number of rows where the count condition is true instead of having php need a large array to count the rows from. If mssql doesn't support count I would be somewhat surprised.
Try this.
@azndragon
He requested ASP, not PHP scripts. ;) Also, concerning the sql you have.. could use just 'SELECT tu_state COUNT(1) FROM t_user' or 'SELECT * COUNT(*) FROM login'. Those I think would just throw back the number of rows where the count condition is true instead of having php need a large array to count the rows from. If mssql doesn't support count I would be somewhat surprised.
#8
Posted 22 April 2004 - 12:28 AM
Didn't read the PHP part, and shouldn't mssql_num_rows work in the same way as you suggestion? The execution time should be very close, not even worth the time it takes to understand the query, cause I never used complex SQL queries :D JOIN was as far as I needed to do what I do.
This post has been edited by azndragon: 22 April 2004 - 12:29 AM
#9
Posted 22 April 2004 - 11:07 AM
Dumb cs classes keep on drilling extreme models to make me code with more efficiency.. try counting the rows of the itemlog table or something, maybe that will sway you over to learning the wonderful joys of sql :D
Share this topic:
Page 1 of 1

Help











