Need help with Online Status

Ladeedadee

New Member
Aug 7, 2019
7
3
Hi.

So.. I'm working on the staffpage in a revcms that I'm using, and I want the ONLINE ICON on each staff to change if they're on/offline

I wonder if someone could help me with this, NOT only what I need to do, but HOW to do it.
 

Joe

Well-Known Member
Jun 10, 2012
4,172
1,955
Does your current page tell you if you’re online or offline? If yes just replace that with the images.

If not there’s 100’s if Staff pages on the forum that have this, simply copy and paste the code.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
You get the online status from the users table , under the column 'online'.

Then use php to determine if the user is online:

$user = [MYSQLGETREQUEST]

while($usr = [MYSQLFETCHASSOCOF$USER])
$onlineStatus = ($usr['online'] == 1) ? "online" : "offline";


echo '<img src="folder/'.$onlineStatus.'">';
 

Chuckie_

Active Member
Jun 22, 2019
138
71
PHP:
$user = mysql_query("SELECT * FROM users");
while($user = mysql_fetch_assoc($user)){
    $isOnline = ($user['online'] == 1) ? 'online' : 'offline';
    echo "<img src='yourimagesfolder'/ . $isOnline . '.filetype'>";
}
Should work. Haven't done raw mysql in a while though.
*EDIT: If you are already working on a staff page, you should already have made your queries according to the different ranks, no?
 
Last edited:

Joe

Well-Known Member
Jun 10, 2012
4,172
1,955
PHP:
if($member['online'] == 1)
{
$online = "<font color='green'><b>Online</b></font>";
} else {
$online = "<font color='red'><b>Offline</b></font>";
}
Pretty sure you could edit this easily as well.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
PHP:
$user = mysql_query("SELECT * FROM users");
while($user = mysql_fetch_assoc($user)){
    $isOnline = ($user['online'] == 1) ? 'online' : 'offline';
    echo "<img src='yourimagesfolder'/ . $isOnline . '.filetype'>";
}
Should work. Haven't done raw mysql in a while though.
*EDIT: If you are already working on a staff page, you should already have made your queries according to the different ranks, no?

You should never select everything from the table, especially the users table. You should select only the columns you are using such as:

"SELECT online FROM users"

The reason for this is because if you have information about your user: password, email, age, etc. all of those become available in that statement, which is how system breaches happen and people get ahold of sensitive information.
 

Users who are viewing this thread

Top