stelthius Posted May 22, 2009 Share Posted May 22, 2009 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.. Quote Link to comment https://forums.phpfreaks.com/topic/159234-solved-user-status/ Share on other sites More sharing options...
MasterACE14 Posted May 22, 2009 Share Posted May 22, 2009 you can't have the else inside the echo like that. Remove it after the 'if' conditional statement. Quote Link to comment https://forums.phpfreaks.com/topic/159234-solved-user-status/#findComment-839824 Share on other sites More sharing options...
MadTechie Posted May 22, 2009 Share Posted May 22, 2009 <td>" . $status = "<font color=\"#04db04\">Online</font><br /> to <td>" . $status = "<font color=\"#04db04\">Online</font><br />"; Quote Link to comment https://forums.phpfreaks.com/topic/159234-solved-user-status/#findComment-839825 Share on other sites More sharing options...
stelthius Posted May 22, 2009 Author Share Posted May 22, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/159234-solved-user-status/#findComment-839835 Share on other sites More sharing options...
MadTechie Posted May 22, 2009 Share Posted May 22, 2009 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/159234-solved-user-status/#findComment-839838 Share on other sites More sharing options...
stelthius Posted May 22, 2009 Author Share Posted May 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/159234-solved-user-status/#findComment-839840 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.