nabrugir
nabrugir

Reputation: 1869

Search number entries on a mysql database with COUNT

I have a mysql database which allocate:

iid, name, description, url, namecategory, idcategory, nametopic, idtopic

How can i know the number of entries that has categoryid=1 and topicid=1?

I've tried

$result = mysql_query("SELECT COUNT(id) 
                         FROM videos 
                        WHERE idcategory = 1 
                          AND idtopic = 1")

...but it hasn't worked!

Upvotes: 0

Views: 115

Answers (2)

Piotr Pankowski
Piotr Pankowski

Reputation: 2406

Run this code and paste the result:

$result = mysql_query("SELECT COUNT(id) AS cnt FROM videos WHERE idcategory=1 AND idtopic=1");
$row = mysql_fetch_assoc ($result);
var_dump ($row);

Upvotes: 1

Axarydax
Axarydax

Reputation: 16603

you have stated that column names are idcategory and idtopic, and in the query you use categoryid and topicid.

Make those match and then try it out.

Upvotes: 0

Related Questions