Jump to content


Photo

urgent! users online only displaying one!


  • Please log in to reply
4 replies to this topic

#1 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 12 September 2006 - 01:29 AM

my users online script is only displaying one user even if two are active in the past 5 minutes...any ideas?

script:
$FiveMinutes = time()-300;
		
	$UsersOnline = Query("Select * From `users` Where `LastActive` >= '" . $FiveMinutes . "'");
		while ($FetchUsers = FetchArray($UsersOnline)) {
			$User = array($FetchUsers['Username']); }
			
	$Template = new Template("templates/ForumStatistics.tpl");
		$Template->Tags(array(
		'MemberCount' => "$MemberCount",
		'ThreadCount' => "$ThreadCount",
		'PostCount' => "$PostCount",
		'UsersOnline' => "" . implode(", ", $User) . ""));
			$Template->Display();

thanks!

#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 12 September 2006 - 01:50 AM

You need

$User[] = $FetchUsers['Username'];

That will add the username into the next entry in the array.

I assume that FetchArray() returns an associative array, not integer-indexed array.

#3 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 12 September 2006 - 01:58 AM

thanks! works perfect!


#4 yong

yong
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 12 September 2006 - 02:20 AM

hi localhost

i also want to do something about count user online,i look yours script ,i have a question ..

like here:"$UsersOnline = Query("Select * From `users` Where `LastActive` >= '" . $FiveMinutes . "'");"

what is "lastActive" and how can you control it?

thanks... 

#5 vrdallas7

vrdallas7
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 12 September 2006 - 02:30 AM

All you have to do is debug what's going on. Take a look at what's in the database. If
the data is there move on to the next thing. Var dump your query. If it shows up in your
print_r($variable) you gotta a template problem.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users