Question about listing all mem

Posted on Sunday 13th May 2007 at 11:37 PM
Diablosblizz
Diablosblizz's Avatar
Hey, I am starting to make a online part, so it shows how many users are online for the RMB Member System. So far I got it where it changes the user number to 1 when they login (so the script will know if they're in or out), and I got it to change it back to 0 when they're logged out.

My problem is, when I attempt to display the users, nothing comes up. I have this code so far:

PHP Code
  1. $onine = mysql_query("SELECT username FROM members WHERE logged = '1' ORDER BY id DESC") or die (mysql_error());
  2. $fetchon = mysql_fetch_array($online);
  3. $current_user_on = $fetchon['username'];
  4. echo "$current_user_on";


Does anybody have any suggestions?

Thanks!
Posted on Monday 14th May 2007 at 01:16 AM
Diablosblizz
Diablosblizz's Avatar
Fixed it myself looking over this code:

PHP Code
  1. $fetchon = mysql_fetch_array($online);
  2.  
  3. Trys to get $ONLINE I had:
  4.  
  5. $onine = mysql_query("SELECT username FROM members WHERE logged = '1' ORDER BY id DESC") or die (mysql_error());
  6.  
  7. I had $onine!! I fixed it :P!!!
Posted on Monday 14th May 2007 at 01:29 AM
Diablosblizz
Diablosblizz's Avatar
I know im triple posting but..

This only displays One Username at a time, and if a different user logins then it changes the username...

So, how can I make it so I shows ALL of the members online. Current Code (shows only one member and it changes):

PHP Code
  1. $onine = mysql_query("SELECT username FROM members WHERE logged = '1' ORDER BY id DESC") or die (mysql_error());
  2. $fetchon = mysql_fetch_array($onine);
  3. $current_user_on = $fetchon['username'];
  4. echo "$current_user_on";


Thanks!
Posted on Monday 14th May 2007 at 04:56 AM
SkillMaster
SkillMaster's Avatar
Code
$onine = mysql_query("SELECT username FROM members WHERE logged = '1' ORDER BY id DESC") or die (mysql_error());
while($fetchon = mysql_fetch_array($onine))
{
$current_user_on = $fetchon['username'];
echo "$current_user_on";
}


That should work
Login or register to respond to this forum topic.