Jump to content

count the number of entrys


AdrianR

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.