Jump to content
MakeWebGames

Staff list error in mccodes 2.03


Ben-Nasha

Recommended Posts

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

Link to comment
Share on other sites

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 by lucky3809
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.....

Link to comment
Share on other sites

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 by lucky3809
Link to comment
Share on other sites

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.   Paste as plain text instead

  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...