Jump to content


Photo

AJAX Users Online


  • Please log in to reply
4 replies to this topic

#1 Alainmeyer1

Alainmeyer1

    Young Padawan

  • Members
  • Pip
  • 8 posts

Posted 08 April 2007 - 07:05 PM

Hey guys, how can I change my script of users online to something that will load every 10 seconds to check for users online?

<?php
$page = 0;
include("header.php");
?>
<div style="text-align:left;padding:15px 10px 0;">
<center><span style="font-size : 20pt;">Users Online</span></center><br>

<?php
// Update online list
$current_time = time();

$sql = "SELECT id, time FROM phpBB3_online";
$result = mysql_query($sql);
while ($values = mysql_fetch_array($result)) {
	if ($current_time - $values['time'] > 60*10) { mysql_query("DELETE FROM phpBB3_online WHERE id = " . $values['id']); }
}

// Get online list
$sql = "SELECT * FROM phpBB3_online ORDER BY time ASC";
$result = mysql_query($sql);
while ($values = mysql_fetch_array($result)) {
	$users_online .= "<tr><td><a href='../phpBB3/memberlist.php?mode=viewprofile&u=" . $values['user_id'] . "'>" . $values['username'] . "</a></td><td>" . date("H:i", $values['time']) . "</td></tr>";
}
if (!isset($users_online)) { $users_online = "<tr><td colspan='2'><i>No one is online.</i></td></tr>"; } else { $users_online = substr($users_online, 0, strlen($users_online) - 3); }
?>


<table align="center" width="100%" border="0">
	<tr>
		<td><b>User</b></td>
		<td><b>Last Click</b></td>
	</tr>
	<?php echo($users_online); ?>
</table>

</div>
<?php include("footer.php"); ?>


#2 Braunson

Braunson

    Young Padawan

  • Members
  • Pip
  • 237 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 08 April 2007 - 08:34 PM

Would this page help? http://wiki.script.a...ow/Ajax.Updater :D You need their JS library tho.

#3 Alainmeyer1

Alainmeyer1

    Young Padawan

  • Members
  • Pip
  • 8 posts

Posted 09 April 2007 - 05:50 AM

Hmmmmm I tried but it doesn't seem to work.

Can someone help me write the script? :D

#4 Demonslay

Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 973 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 09 April 2007 - 01:20 PM

Simple Ajax.PeriodicalUpdater works just fine.

Just pass it the container, URL of the PHP script to request from, and an optional object with the method and frequency of the updates.

Of course you need to download the Prototype library, which is simple enough to use.

#5 fbUnfimemilkism

fbUnfimemilkism

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 21 October 2012 - 04:15 PM

no




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users