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!!!

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'

Archived

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

×
×
  • 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.