CBaZ Posted July 24, 2007 Share Posted July 24, 2007 i have an issue with this $result2 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '0'"); $row = mysql_fetch_array($result2); $result3 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '1'"); $row2 = mysql_fetch_array($result3); echo "ATM:" . ($usersOnline != 1 ? "" : "") . " $usersOnline Admin" . ($usersOnline != 1 ? "s" : "") ." / $row2[count]" . ", " . ($usersOnline != 1 ? "" : "") . " $usersOnline User" . ($usersOnline != 1 ? "s" : "") ." / $row[count]" . ". "; permission 0 are regular users permission 1 are admins. for some reason the regulars are ok but admins are not.. when one person logs in it will add 2 and when more sign in the number goes up for admin and regulars something is really screwy here any ideas? Link to comment https://forums.phpfreaks.com/topic/61475-users-online/ Share on other sites More sharing options...
redarrow Posted July 24, 2007 Share Posted July 24, 2007 your counting the number of 0 and 1's lol the code is correct what is it u want? Link to comment https://forums.phpfreaks.com/topic/61475-users-online/#findComment-305974 Share on other sites More sharing options...
CBaZ Posted July 24, 2007 Author Share Posted July 24, 2007 i want it to count the 2 admin users seperately right now its throwing it all together. the regulars and the admins before i just had the regulars that was fine but i thought i could add the admins as well Link to comment https://forums.phpfreaks.com/topic/61475-users-online/#findComment-305980 Share on other sites More sharing options...
mmarif4u Posted July 24, 2007 Share Posted July 24, 2007 I think use one query for all, And then in if statement do it like this if (permission== 0) { regular user code here} else {admin code here} Hope this will give u some idea. Link to comment https://forums.phpfreaks.com/topic/61475-users-online/#findComment-305983 Share on other sites More sharing options...
CBaZ Posted July 24, 2007 Author Share Posted July 24, 2007 something like this? if (permission== 1) { echo "ATM:" . ($usersOnline != 1 ? "" : "") . " $usersOnline Admin" . ($usersOnline != 1 ? "s" : "") ." / $row2[count]" . ", "; } else { ". ($usersOnline != 1 ? "" : "") . " $usersOnline User" . ($usersOnline != 1 ? "s" : "") ." / $row[count]" . ". "; } Link to comment https://forums.phpfreaks.com/topic/61475-users-online/#findComment-306008 Share on other sites More sharing options...
mmarif4u Posted July 24, 2007 Share Posted July 24, 2007 Yeh like that, Try it, it will work hopefully for u. Link to comment https://forums.phpfreaks.com/topic/61475-users-online/#findComment-306018 Share on other sites More sharing options...
CBaZ Posted July 24, 2007 Author Share Posted July 24, 2007 it has sum bugs. its not working for me as of now i am sure i gotta change the code the dots ahhh Link to comment https://forums.phpfreaks.com/topic/61475-users-online/#findComment-306021 Share on other sites More sharing options...
CBaZ Posted July 24, 2007 Author Share Posted July 24, 2007 if (permission == 1) { echo "ATM:" . ($usersOnline != 1 ? "" : "") . " $usersOnline Admin" . ($usersOnline != 1 ? "s" : "") ." of $row2[count]" . ", "; } else { echo "ATM:" . ($usersOnline != 1 ? "" : "") . " $usersOnline User" . ($usersOnline != 1 ? "s" : "") ." of $row[count]" . ". "; } this produces no more admin = 0 when logged in as admin says 2 users of 26 online hmmmph Link to comment https://forums.phpfreaks.com/topic/61475-users-online/#findComment-306025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.