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. Quote 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] Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.