PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$query=mysql_query("SELECT * FROM current_online");
while($fetch=mysql_fetch_array($query))
{
$username[]=fetch['username'];
}
while(1) {
echo '<script type="text/javascript">';
// echo 'comet.printServerTime('.time().');';
echo 'comet.printServerTime('.time().');';
echo '</script>';
flush(); // used to send the echoed data to the client
sleep(1); // a little break to unload the server CPU
}
?>
$query=mysql_query("SELECT * FROM online");
while($fetch=mysql_fetch_array($query))
{
$username[]=$fetch['username'];
}
foreach($username as $usernames)
{
$name.=$usernames.",";
}
//echo $name;
while(1) {
echo '<script type="text/javascript">';
// echo 'comet.printServerTime('.time().');';
echo 'comet.printServerTime('.$name.');';
echo '</script>';
flush(); // used to send the echoed data to the client
sleep(1); // a little break to unload the server CPU
}
?>
If one observes google talk, the instant a user closes his browser, Other users will see him as logged out. How this has been done?
I can understand that when a user logs out, we can enter in a flag field and check if he has logged out or not, how to do when a user closes his browser?
If they use ajax, could they not just update a script onunload() of a page?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
<?php
...
$query_num=mysql_num_rows(mysql_query("SELECT * FROM online"));
while($query_num > 0) {
$online='';
$query=mysql_query("SELECT * FROM online");
while($fetch=mysql_fetch_array($query))
{
//$online_arr="";
$online[]=$fetch['userid'];
}
$online_arr=implode(',',$online);
// $online_arr=time();
echo '<script type="text/javascript">';
echo "comet.printServerTime('$online_arr')";
echo '</script>';
flush(); // used to send the echoed data to the client
sleep(1); // a little break to unload the server CPU
?>
It works fine. But, if i leave the window or does not do anything, it does not work. I have to refresh again to make it work. Otherwise whenever i insert or delete from database, it gets updated automatically. Can anyone tell me how to make it work?
In fact, in the orginal file also, the time runs for some 30 seconds and stops
I need to create an infinite loop and check the condition for current online users, when i use this script, it flushes every second. Can anyone give me a better way to implement the infinite loop and check for the conditon?