FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

PHP Whos Online Code OR Page refresh..

 


Diablosblizz
Okay, I got a slight problem. I want to have a "Whos Online" script on my site, the only problem is that my site runs on Iframes, and the Online Script doesn't refresh, so the only way I could make it refresh was in a iframe (by refresh I don't want the WHOLE page to refresh, just the Whos online)

My problem is that if I try to put the online code in a iframe (that's the only way I know how to refresh) then the code does not work properly.

So, what I need is:

A Whos Online script that WILL work with my members system (I'll post the original code) AND works in an iframe.

OR

A script that refreshes the Whos Online script WITHOUT refreshing the whole page.

Any one will do!!!

The code below displays the users:

Code:
<?php
error_reporting(0);
include("members/config.php");
include("members/online.php"); //get online configuration and such
$get_online_users = mysql_query("SELECT * FROM `members` WHERE `online` >= '$offline' ORDER BY `userlevel` ASC"); //get all online users
$total_users = mysql_num_rows($get_online_users);
if($total_users == 0){ //see if anyone is logged in
    echo "No Users Online!"; //there isn't =O
}else{ //maybe....
    $i = 1; //the variable 'i' is 1
    while($online = mysql_fetch_array($get_online_users)){ //loop online users
        if(($i > 0) && ($i != $total_users)){ //see if i is the same or not of total online users
            $comma = ', '; //if it isn't then theres a comma
        }else{ //or....
            $comma = ''; //if there isn't theres no comma
        } //end check
        if($online['userlevel'] == 6) {
        echo "<a href='members/members.php?page=view&username=$online[username]' target='content'><font color='orange'>$online[username]</a>$comma"; //echo the online users with the comma
        }
    } //end loop
} //end
?>
<head>
<meta http-equiv='Refresh' content='30; URL=online.php'/>
<style>
body {
       color: black;
       font-size: 10px;
       font-family: verdana;
}
</style>
</head>


The code below updates the member and sets them as online and offline if after 30 seconds:

Code:
<?php
include('config.php');
$logout_time = 10; //mili seconds to stay logged in
$current = time(); //current time
$offline = ($current - $logout_time); //do the math for the logout time
if($logged[username]){ //if they are logged in
    $update = mysql_query("UPDATE `members` SET `online` = '$current' WHERE `username` = '$logged[username]';"); //update their status
} //end the check and such
?>



PLEASE AND THANK YOU!
~Keith.
DjinniFire
why would you need a refresh for online script?
Not really sure the intentions of needing it to continuously refresh :/ As long as a person moves from page to page I would think that is good enough for refresh of online script.
vinx_18
-- To refresh or reload php page, you can use "Meta" --
e.g
<META HTTP-EQUIV=Refresh CONTENT="3; URL=http://www.yoursite.com/yoururl.php">

It will refresh in every 3 seconds. You can change 3 to number you like.
Diablosblizz
Fire,

Read my post again, my site runs on Iframes, so the content is just refreshing, NOT the whole page.

Vinx,

The meta refresh would refresh the whole page, not just the online script.



All I want it to do is refresh the online script, not the whole page!

Thanks.
snowboardalliance
Diablosblizz wrote:
Fire,

Read my post again, my site runs on Iframes, so the content is just refreshing, NOT the whole page.


What? If the content is refreshing, couldn't your script be placed along with this "content" in the same iframe? Maybe I just don't understand what you mean by "my site runs on Iframes."
DjinniFire
I'm just confused at the whole premise of what you are trying to do.
Like I understand the problem just not understanding the purpose of your system with iframes.
Diablosblizz
Okay, I don't think I am going to be able to explain it any better, so just take a look at my site:

http://hotelmario.info/main.php

Click around, notice how EVERYTHING is pretty much in iframes? Well, if I put the script in the main.php file (where the template and iframes are) and add a meta refresh then it will refresh the whole page.

I don't want that, I just want it to refresh the whos online script (which currently there isn't one at my site)

So, what I need is a whos online script that works in iframes (because mine doesn't) OR a refresh script that doesn't refresh my whole page (including template)

Hope you understand!
Dougie1
Weird... So that is refreshing the whole page? That is unfortunate. Just use ajax then and make it call on the page every 5 seconds or so to see if anyone else is there. There are some very easy tutorials on the internet and it is not as hard as it sounds.
Diablosblizz
I don't even know what Ajax is... :S
manav
there is a solution for this in AJAX... its Asynchronous Java Script with XML.... many tutorials r there on the net....search on google...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.