Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 76
0 Users 5 Guests Online
Forum Index » PHP + MySQL » Question about listing all mem
Posted on Sunday 13th May 2007 at 11:37 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
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
2
3
4
$onine = mysql_query("SELECT username FROM members WHERE logged = '1' ORDER BY id DESC") or die (mysql_error());
$fetchon = mysql_fetch_array($online);
$current_user_on = $fetchon['username'];
echo "$current_user_on";


Does anybody have any suggestions?

Thanks!
Posted on Monday 14th May 2007 at 01:16 AM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Fixed it myself looking over this code:

PHP Code
1
2
3
4
5
6
7
8
$fetchon = mysql_fetch_array($online); 

Trys to get $ONLINE I had:

$onine = mysql_query("SELECT username FROM members WHERE logged = '1' ORDER BY id DESC") or die (mysql_error());

I had $onine!! I fixed it :P!!!
Posted on Monday 14th May 2007 at 01:29 AM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
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
2
3
4
$onine = mysql_query("SELECT username FROM members WHERE logged = '1' ORDER BY id DESC") or die (mysql_error());
$fetchon = mysql_fetch_array($onine);
$current_user_on = $fetchon['username'];
echo "$current_user_on";


Thanks!
Posted on Monday 14th May 2007 at 04:56 AM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
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