$numComments = mysql_query("SELECT COUNT(id_post) FROM comments WHERE id_post = '". $row["id"]."' ");
// it works if I do this: echo mysql_result($numComents,0);
if ($numComments > 0){
echo mysql_result($numComments,0);
}else{
}
$result = mysql_query("SELECT COUNT(id_post) FROM comments WHERE id_post = '". $row["id"]."' ");
$numComments = mysql_result($result,0);
if ( $numComments > 0) {
echo $numComments ;
} else {
//do something...
}
$number_of_rows = mysql_fetch_row($numComments)[0];
echo $number_of_rows > 0 ? $number_of_rows : '';