I am trying to get the number comments for different post. I have all the comments for my archives stored in one table within my database...
here is the code I am trying to use...
<?
$com_id = $id;
$host = "localhost";
$user = "root";
$password = "**********";
$database = "bizat";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to database.");
$db = mysql_select_db("$database",$connection)
or die ("Couldn't select database.");
$query = "SELECT * FROM comments WHERE `com_id`='$com_id'";
$result = mysql_query($query)
or die ("Couldn't ececute query.");
$com_rows = mysql_num_rows($result);
if ($com_rows) {
echo " $com_rows ";
}
else {
echo " 0 ";
}
?>
Any Ideas?