Jump to content

[SOLVED] Counting all the entires in database


Fsoft

Recommended Posts

`Hello,


$query10 = mysql_query("SELECT * from articles where art_cat = $cat");

echo "  ";
echo "There are ";
$count = 0;

while($query11 = mysql_fetch_array($query10))
{
$countfinal = $count+1;
}
echo $countfinal;
}

 

 

Sir, I am stuck here, I have 19 articles in my table, And I want to echo out "There are 19 articles."

 

Using this code it only gives out There are 1 articles.. I don't know why this code is not working :(

 

Please help, thanks.

 

FAISAL!!!

Link to comment
Share on other sites

Do this:

 

$query10 = mysql_query("SELECT COUNT(id) from articles where art_cat = $cat");
$row10 = mysql_fetch_assoc($query10);
echo "There are {$row['COUNT(id)']} articles";

 

Change COUNT(id) to another row in that table if you don't have 'id'

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.