Jump to content

[SOLVED] User status


stelthius

Recommended Posts

Ok guys i hope someone here can help me out with my nightmare lol...

 

I have a user list it shows a bunch of details for users, the last one im struggling with is status, on/offline... i have got this code...

 

 

$query = mysql_query("SELECT u.username FROM ".TBL_USERS." u INNER JOIN ".TBL_ACTIVE_USERS." a ON a.username=u.username WHERE a.timestamp < (NOW() - INTERVAL 5 MINUTE) AND u.username= '$b->username'")or die(mysql_error());
if (mysql_num_rows($query) > 0){
}


echo "<tr>
<td><img src='include/avatar/" . $value[$x]['username'] . "/" . $value[$x]['avatar'] . "' width='80' height='80' /></td>
<td>" . $value[$x]['username'] . "</td>
<td>" . $value[$x]['email'] . "</td>
<td>" . $value[$x]['sex'] . "</td>
<td>" . $value[$x]['month'] . " " . $value[$x]['day'] . ", " . $value[$x]['year'] . "</td>
<td>" . $value[$x]['signupdate'] . "</td>
<td>" . $status = "<font color=\"#04db04\">Online</font><br />
}else{
    " . $status = "<font color=\"#FF0000\">Offline<br /></font>";
}
echo '</table>';

 

but in the table its just showing

 

Online
}else{ Offline

 

I really cant work out how to get this to work ive been trying for atleast 2 hours now, can anyone shed any light on this relatively dumb question lol.

 

Many thanks for any help..

Link to comment
Share on other sites

After trying both of you're suggestions neither worked... so i tried the following which gave me what i needed but failed to give me any results.. it seems each time i almost get it to work it stops giving me results lol

 

$query = mysql_query("SELECT u.username FROM ".TBL_USERS." u INNER JOIN ".TBL_ACTIVE_USERS." a ON a.username=u.username WHERE a.timestamp < (NOW() - INTERVAL 5 MINUTE) AND u.username= '$b->username'")or die(mysql_error());
if (mysql_num_rows($query) > 0)
{
$status = "<font color=\"#04db04\">Online</font><br />";
}else{
$status = "<font color=\"#FF0000\">Offline<br /></font>";
}}
echo"
<tr>
<td><img src='include/avatar/" . $value[$x]['username'] . "/" . $value[$x]['avatar'] . "' width='80' height='80' /></td>
<td>" . $value[$x]['username'] . "</td>
<td>" . $value[$x]['email'] . "</td>
<td>" . $value[$x]['sex'] . "</td>
<td>" . $value[$x]['month'] . " " . $value[$x]['day'] . ", " . $value[$x]['year'] . "</td>
<td>" . $value[$x]['signupdate'] . "</td>
<td>" . $status . "</td></tr>";

 

I really appretiate the time help too guys

 

 

*EDIT*

 

I get no errors, i just simply get no results in my table, sorry forgot to add that

Link to comment
Share on other sites

 

Your code should be like this

$query = mysql_query("SELECT u.username FROM ".TBL_USERS." u INNER JOIN ".TBL_ACTIVE_USERS." a ON a.username=u.username WHERE a.timestamp < (NOW() - INTERVAL 5 MINUTE) AND u.username= '$b->username'")or die(mysql_error());
if (mysql_num_rows($query) > 0)
{
$status = "<font color=\"#04db04\">Online</font><br />";
}else{
$status = "<font color=\"#FF0000\">Offline<br /></font>";
}

echo"
<tr>
<td><img src='include/avatar/" . $value[$x]['username'] . "/" . $value[$x]['avatar'] . "' width='80' height='80' /></td>
<td>" . $value[$x]['username'] . "</td>
<td>" . $value[$x]['email'] . "</td>
<td>" . $value[$x]['sex'] . "</td>
<td>" . $value[$x]['month'] . " " . $value[$x]['day'] . ", " . $value[$x]['year'] . "</td>
<td>" . $value[$x]['signupdate'] . "</td>
<td>" . $status . "</td></tr>";

Link to comment
Share on other sites

Hello guys, in the end i ended up doing this,

 

$query = mysql_query("SELECT u.username FROM ".TBL_USERS." u INNER JOIN ".TBL_ACTIVE_USERS." a ON a.username=u.username WHERE a.timestamp < (NOW() - INTERVAL 5 MINUTE) AND u.username= '$b->username'")or die(mysql_error());
if (mysql_num_rows($query) > 0)
{
$status = "<font color=\"#04db04\">Online</font><br />";
}else{
$status = "<font color=\"#FF0000\">Offline<br /></font>";
}

print "
<tr>
<td><img src='include/avatar/" . $value[$x]['username'] . "/" . $value[$x]['avatar'] . "' width='80' height='80' /></td>
<td>" . $value[$x]['username'] . "</td>
<td>" . $value[$x]['email'] . "</td>
<td>" . $value[$x]['sex'] . "</td>
<td>" . $value[$x]['month'] . " " . $value[$x]['day'] . ", " . $value[$x]['year'] . "</td>
<td>" . $value[$x]['signupdate'] . "</td>
<td>".$status."</td>
</tr>\n";
}
print "</table>\n";

 

For some unknow reason i didnt try this earlier dont ask me why, morning thickness i guess lol, thanks again for your help guys very much appretiated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.