wolvez Posted May 7, 2012 Share Posted May 7, 2012 im creating a members website and i want to show how many people are logging, in my database i have a col named online every time somone logs in there online goes from 0 to 1 and when thay log out it goes back to 0. i need to know how to show the total people that have 1 in there online part of the data base iv tryed this code and its not working <?php $result = mysql_query("SELECT online FROM `members` WHERE online='1'"); $row = mysql_fetch_row($result); echo $row; ?> this works in the sql console in phpmyadmin Quote Link to comment Share on other sites More sharing options...
wigwambam Posted May 7, 2012 Share Posted May 7, 2012 <?php $result = mysql_query("SELECT online FROM `members` WHERE online='1'"); echo mysql_num_rows($result); ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 7, 2012 Share Posted May 7, 2012 SELECT count(online) as count_online FROM members WHERE online=1 Quote Link to comment Share on other sites More sharing options...
wolvez Posted May 7, 2012 Author Share Posted May 7, 2012 iv tryed still not working this is what im getting Warning: mysql_num_rows() expects parameter 1 to be resource, boolean Quote Link to comment Share on other sites More sharing options...
wigwambam Posted May 7, 2012 Share Posted May 7, 2012 Sounds like the query has failed. What data type is 'online' - have you opened the database? Try: $result = mysql_query("SELECT online FROM `members` WHERE online='1'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
wolvez Posted May 7, 2012 Author Share Posted May 7, 2012 i forget to move the $connect to this php code its now working Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.