Jump to content

Archived

This topic is now archived and is closed to further replies.

AdrianR

count the number of entrys

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.