fife Posted April 1, 2011 Share Posted April 1, 2011 Hi I have this code and when I echo the count it shows 1 when theres actually 5. Have I wrote it wrong $loginsq = mysql_query("SELECT email FROM logindetails WHERE email = ".$_SESSION['MM_Username'].""); $logins = mysql_fetch_array($loginsq); $logs = count($logins); echo $logs; Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 1, 2011 Share Posted April 1, 2011 mysql_fetch_array() gets the next (i.e. one) record from the result set. You are only retrieving one field, "email", so the count() for any one record would only be 1. If you want the number of records in the query result set you would use $logs = mysql_num_rows($loginsq); Quote Link to comment Share on other sites More sharing options...
ravens_chance Posted April 1, 2011 Share Posted April 1, 2011 You can also just use you query to get your count: $loginsq = mysql_query("SELECT COUNT(email) FROM logindetails WHERE email = ".$_SESSION['MM_Username'].""); Quote Link to comment Share on other sites More sharing options...
fife Posted April 1, 2011 Author Share Posted April 1, 2011 cool guys cheers 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.