Ben-Nasha Posted June 22, 2011 Posted June 22, 2011 On my stafflist it doesnt display the staff names (i am staff) here is my file <?php include_once "globals.php"; $staff = array(); $q = $db->query("SELECT `userid` FROM `users` WHERE `user_level` IN(2,3,5) ORDER BY `userid` ASC"); while ( $r = $db->fetch_row($q) ) { $staff[$r['userid']] = $r; } echo ' <b>Admins</b> <br /> <table width="75%" cellspacing="1" cellpadding="1" class="table"> <tr style="background:gray"> <th>User</th> <th>Level</th> <th>Money</th> <th>Last Seen</th> <th>Status</th> </tr> '; foreach ( $staff as $r ) { if ( $r['user_level'] == 2 ) { $on = ( $r['laston'] >= ($_SERVER['REQUEST_TIME'] - 15) * 60 )?'<span style="color: green;">Online</span>':'<span style="color: green;">Offline</span>'; echo ' <tr> <td><a href="viewuser.php?u='.$r['userid'].'">'.$r['username'].'</a> ['.$r['userid'].']</td> <td>'.$r['level'].'</td> <td>'.money_formatter($r['money'],'$').'</td> <td>'.date("F j, Y, g:i:s a",$r['laston']).'</td> <td>'.$on.'</td> </tr> '; } } echo '</table> <b>Secretaries</b> <br /> <table width="75%" cellspacing="1" cellpadding="1" class="table"> <tr style="background:gray"> <th>User</th> <th>Level</th> <th>Money</th> <th>Last Seen</th> <th>Status</th> </tr> '; foreach ( $staff as $r ) { if ( $r['user_level'] == 3 ) { $on = ( $r['laston'] >= ($_SERVER['REQUEST_TIME'] - 15) * 60 )?'<span style="color: green;">Online</span>':'<span style="color: green;">Offline</span>'; echo ' <tr> <td><a href="viewuser.php?u='.$r['userid'].'">'.$r['username'].'</a> ['.$r['userid'].']</td> <td>'.$r['level'].'</td> <td>'.money_formatter($r['money'],'$').'</td> <td>'.date("F j, Y, g:i:s a",$r['laston']).'</td> <td>'.$on.'</td> </tr> '; } } echo '</table> <b>Assistants</b> <br /> <table width="75%" cellspacing="1" cellpadding="1" class="table"> <tr style="background:gray"> <th>User</th> <th>Level</th> <th>Money</th> <th>Last Seen</th> <th>Status</th> </tr> '; foreach( $staff as $r ) { if ( $r['user_level'] == 5 ) { $on = ( $r['laston'] >= ($_SERVER['REQUEST_TIME'] - 15) * 60 )?'<span style="color: green;">Online</span>':'<span style="color: green;">Offline</span>'; echo ' <tr> <td><a href="viewuser.php?u='.$r['userid'].'">'.$r['username'].'</a> ['.$r['userid'].']</td> <td>'.$r['level'].'</td> <td>'.money_formatter($r['money'],'$').'</td> <td>'.date("F j, Y, g:i:s a",$r['laston']).'</td> <td>'.$on.'</td> </tr> '; } } echo '</table>'; $h->endpage(); ?> Please post a fix Quote
lucky3809 Posted June 22, 2011 Posted June 22, 2011 (edited) add username to this query... $q = $db->query("SELECT `userid` FROM `users` WHERE `user_level` IN(2,3,5) ORDER BY `userid` ASC"); You may also want to add level too and the money,laston fields...basically all the fields in the script that has $r['.... $q = $db->query("SELECT `userid`,`username`,`level`,`money`,`laston` FROM `users` WHERE `user_level` IN(2,3,5) ORDER BY `userid` ASC"); Edited June 22, 2011 by lucky3809 Quote
Mystical Posted June 22, 2011 Posted June 22, 2011 Replace: $q = $db->query("SELECT `userid` FROM `users` WHERE `user_level` IN(2,3,5) ORDER BY `userid` ASC"); With $q=$db->query("SELECT * FROM users WHERE user_level IN(2,3,5) ORDER BY userid ASC"); Works. Quote
Ben-Nasha Posted June 22, 2011 Author Posted June 22, 2011 Thanks it displays the name now but it says am offline when am online. Quote
Mystical Posted June 22, 2011 Posted June 22, 2011 add username to this query... $q = $db->query("SELECT `userid` FROM `users` WHERE `user_level` IN(2,3,5) ORDER BY `userid` ASC"); You may also want to add level too and the money,laston fields...basically all the fields in the script that has $r['.... $q = $db->query("SELECT `userid`,`username`,`level`,`money`,`laston` FROM `users` WHERE `user_level` IN(2,3,5) ORDER BY `userid` ASC"); This does not work either. Doesn't show anything. Quote
lucky3809 Posted June 24, 2011 Posted June 24, 2011 (edited) replace your time with if($r['laston'] >= time()-15*60){$on="<font color=green><b>Online</b></font>";} else {$on="<font color=green><b>Offline</b></font>";} Edited June 24, 2011 by lucky3809 Quote
Mystical Posted June 24, 2011 Posted June 24, 2011 replace your time with if($r['laston'] >= time()-15*60){$on="<font color=green><b>Online</b></font>";} else {$on="<font color=green><b>Offline</b></font>";} I think you misunderstood. Nothing shows at all. Nothing. No time no level no money no name no nothing..... Quote
lucky3809 Posted June 24, 2011 Posted June 24, 2011 (edited) Did not misunderstood he wrote "Thanks it displays the name now but it says am offline when am online. " And what you provided him is selecting the WHOLE users table he does not need to select every single field, he only needs fields that are in his echo / IF statements! I added exactly what he has and the query i provided and it worked fine on my server, if he is getting absolutely NOTHING then he does not have those fields in his database, however he did not mean it shows NOTHING he meant it does not show the time as for his code with $_SERVER['REQUEST_TIME'] is not working and not pulling his server time, so i provided him another solution to that.. which was time(). Edited June 24, 2011 by lucky3809 Quote
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.