Jump to content

Archived

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

corillo181

help out a little here..

Recommended Posts

so i'm trying to count the rows in a table ..

the situation is as fallow.. someone leaves a comment about something.. the id goes in to the comment table.. now i want to count how many times ppl left comment about that one thing.. this is what i tried but it dont work..
[code=php:0]
$rows=mysql_query("SELECT comment_id FROM pcomment WHERE photo_id='pic_id' ");
$countrow=mysql_num_rows($rows);

echo $countrow;
[/code]

Share this post


Link to post
Share on other sites
Hi,
this should do:
SELECT count(comment_id) FROM pcomment WHERE photo_id='pic_id'

Full explanation at [a href=\"http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html[/a]

Regards,
Andi

Share this post


Link to post
Share on other sites

×

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.