Newbie Spellweaver
- Joined
- Dec 23, 2008
- Messages
- 46
- Reaction score
- 29
Here is a small script to list all user_id's that are currently online
WARNING!
- THIS PULLS 1 QUERY EVERY 3 SECONDS -
- Thats 20 query's in 1min
- Thats 1200 every hour!
You can change the time, on line 21 (in online.html) you'll find: 3000 = 3 sec
online.html
onlineusers.php
WARNING!
- THIS PULLS 1 QUERY EVERY 3 SECONDS -
- Thats 20 query's in 1min
- Thats 1200 every hour!
You can change the time, on line 21 (in online.html) you'll find: 3000 = 3 sec
online.html
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Live Users</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
setInterval(function(){
$('#online').load('onlineusers.php');}, 3000);
</script>
<div id="online">Loading online list...</div>
</body>
</html>
onlineusers.php
PHP:
<?php
// Insert your MSSQL info here
$mssql = array(
'host' => "YOUR HOST",
'user' => "YOUR USER",
'pass' => "YOUR PASS"
);
$mslink = mssql_connect($mssql['host'],$mssql['user'],$mssql['pass']);
$login = "1100";
$result1 = mssql_query("SELECT * FROM account.dbo.user_profile WHERE login_flag = '".$login."' ",$mslink);
while($array = mssql_fetch_array($result1)){
echo $array['user_id'] . "<br>";
}
?>