Jump to content

Recommended Posts

I have a table with 5 rows:

data1

data1

data1

data1

data2

 

I want to count only data1. How can I do that?

 

Tried the below but couldn't get it to work

$select = 'SELECT * FROM data WHERE data=data1';

if ($result = mysql_query ($select)) {
while ($row = mysql_fetch_array ($result)) {
$data1 = $row['data'];
echo "$data1";             
             }
}

Why don't you just SELECT * FROM data WHERE data='data1' then use mysql_num_rows to get the number?

 

How would I echo the amount of rows with mysql_num_rows? I know how to echo the field in the while loop but not the number of rows it returns.

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.