Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mko
Forum Newbie
Posts: 1
Joined: Fri Nov 12, 2010 4:29 pm

Help

Post by Mko »

I have this following code in a file:

Code: Select all

$OnlineUsers     = $db->query("SELECT `id`,`username` FROM ".USERS." WHERE `onlinetime` >= '".(TIMESTAMP-10*60)."';");
	while ($UserRow = $db->fetch_array($OnlineUsers))
	
	$OnlineAdmins 	= $db->query("SELECT `id`,`username` FROM ".USERS." WHERE `onlinetime` >= '".(TIMESTAMP-10*60)."' AND `authlevel` > '0';");
	while ($AdminRow = $db->fetch_array($OnlineAdmins)) {
		$AdminsOnline[$AdminRow['id']]	= $AdminRow['username'];
	}

	$db->free_result($OnlineAdmins);

	$template->assign_vars(array(
		'AdminsOnline'				=> $AdminsOnline,
		'UsersOnline'				=> $UsersOnline,
	));
Which is used in this in this:

Code: Select all

<div id="content" class="content">
    <table class="table519">
        <tr>
        	<td style="white-space: nowrap;">Players Online</td>
        	<td colspan="3"><font color=lime>{$OnlineUsers}</font> players currently online.</td>
        </tr>
        <tr>
        	<td style="white-space: nowrap;">Admins Online</td>
        	<td colspan="3">{foreach name=OnlineAdmins key=id item=Name from=$AdminsOnline}{if !$smarty.foreach.OnlineAdmins.first}&nbsp;&bull;&nbsp;{/if}<a href="#" onclick="OpenPopup('game.php?page=messages&mode=write&id={$id}','', 720, 300);return false;">{$Name}</a>{foreachelse}{$ov_no_admins_online}{/foreach}</td>
        </tr>	
</table>
</div>
I have coded in the OnlineUsers myself, and the AdminsOnline code was there before.

What am I doing incorrectly, because on my site, the OnlineUsers amount doesn't show.


Thanks,
Mko.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help

Post by Celauran »

You've specified

Code: Select all

while ($UserRow = $db->fetch_array($OnlineUsers))
but aren't doing anything with it. The same code for admin users iterates through the rows, storing values in an array.
Post Reply