DrTrans Posted August 24, 2009 Share Posted August 24, 2009 $query2 = "COUNT * FROM property WHERE Owner_ID = '$ownerid'"; $result2 = mysql_query($query2); print"<b>Amount of Properties Owned:</b> $result2"; Basically i want it to count how many times it finds that match and display a number. Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/ Share on other sites More sharing options...
merck_delmoro Posted August 24, 2009 Share Posted August 24, 2009 try this $query2 = "SELECT * FROM property WHERE Owner_ID = '$ownerid'"; $result2 = mysql_query($query2); echo "<b>Amount of Properties Owned:</b>".count($result2); Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905385 Share on other sites More sharing options...
DrTrans Posted August 24, 2009 Author Share Posted August 24, 2009 That gives a value of "1" but i know in the database there are 7 records. Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905387 Share on other sites More sharing options...
kickstart Posted August 24, 2009 Share Posted August 24, 2009 Hi Try this:- $query2 = "SELECT COUNT(*) FROM property WHERE Owner_ID = '$ownerid'"; $result2 = mysql_query($query2); if ($row(mysql_fetch_array($result2))) print"<b>Amount of Properties Owned:</b> ".$row[0]; All the best Keith Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905388 Share on other sites More sharing options...
merck_delmoro Posted August 24, 2009 Share Posted August 24, 2009 my mistake the one that I count is the query not its records inside the query the Post DrTrans was correct Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905391 Share on other sites More sharing options...
DrTrans Posted August 24, 2009 Author Share Posted August 24, 2009 Neither of these solutions have worked Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905396 Share on other sites More sharing options...
DrTrans Posted August 24, 2009 Author Share Posted August 24, 2009 in responce to kick: Fatal error: Function name must be a string Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905399 Share on other sites More sharing options...
kickstart Posted August 24, 2009 Share Posted August 24, 2009 Hi Err, doh. $query2 = "SELECT COUNT(*) FROM property WHERE Owner_ID = '$ownerid'"; $result2 = mysql_query($query2); if ($row = mysql_fetch_array($result2)) print"<b>Amount of Properties Owned:</b> ".$row[0]; Sorry. All the best Keith Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905408 Share on other sites More sharing options...
DrTrans Posted August 24, 2009 Author Share Posted August 24, 2009 Thanks man, I completely didnt even notice the = was missing either.. Im sitting here like WTF Thanks .. Link to comment https://forums.phpfreaks.com/topic/171698-solved-couting-records/#findComment-905410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.