IF user online [PHP]

Status
Not open for further replies.

zMagenta

Posting Freak
Jul 15, 2011
1,414
682
Hello!

Been working on a CMS recently. This is for Habbo, but it's nothing to do with Habbo directly. (If that makes sense?)

What I would like is it to show an image if the user is online, and a different one if the user is offline. It's defined where a user is offline/online in the 'users' table, via the column 'online' (1 = yes, 0 = no).

I started this;

Code:
<?php
$getmain4 = mysql_query("SELECT online FROM users WHERE username = 'zMagenta'");
while($muslim5 = mysql_fetch_array($getmain4))
{
?>

Then <img src="{url}/app/tpl/skins/{skin}/images/offline1.gif?1"/> this is what needs to be shown when you're offline ('0') but when online I need it to show
<img src="{url}/app/tpl/skins/{skin}/images/online1.gif?1"/>

If you understand this, it'll be a great help if someone can help me out here.
 

Kaz

BooYah
Staff member
Nov 16, 2010
3,064
1,025
I presume you have knowledge with querys etc...

It should look like this:
if($query == 1) {
echo 'online image';
} else {
echo 'offline image';
}
 

zMagenta

Posting Freak
Jul 15, 2011
1,414
682
I presume you have knowledge with querys etc...

It should look like this:
if($query == 1) {
echo 'online image';
} else {
echo 'offline image';
}

Worked a dream, I ended up doing this.

PHP:
<?php
$getmain4 = mysql_query("SELECT online FROM users WHERE username = 'zMagenta'");
while($muslim5 = mysql_fetch_array($getmain4))
{
?>
                <div style="float:left; padding-top: 5px;">
                <?php
                if($getmain4 == 1) {
echo '<img src="{url}/app/tpl/skins/{skin}/images/online1.gif?1"></img>';
} else {
echo '<img src="{url}/app/tpl/skins/{skin}/images/offline1.gif?1"></img>';
}
}
?>

Thread can now be closed.
 
Status
Not open for further replies.

Users who are viewing this thread

Top