AdrianR Posted March 12, 2006 Share Posted March 12, 2006 Hi people.Someone told me a few days ago how to count the number of entrys in a field but I can`t make it work.I want to count only the number of entrys with text"content" and "content2"here is what I`ve done:$s=SQLSELECT COUNT(field_name) FROM table_name where fieldname=content or fieldname=content2;echo $s;But it dosen`t work,I get errors. Link to comment https://forums.phpfreaks.com/topic/4747-count-the-number-of-entrys/ Share on other sites More sharing options...
Barand Posted March 12, 2006 Share Posted March 12, 2006 try[code]$result=mysql_query("SELECT COUNT(field_name) FROM table_name");echo mysql_result ($result,0,0);[/code]To count those with specific values[code]$result=mysql_query("SELECT COUNT(*) FROM table_name WHERE (field_name = 'content1') OR (field_name = 'content2' ");echo mysql_result ($result,0,0);[/code] Link to comment https://forums.phpfreaks.com/topic/4747-count-the-number-of-entrys/#findComment-16661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.