SHARE
TWEET

Untitled

a guest Jan 14th, 2013 5 Never
  1. $numComments = mysql_query("SELECT COUNT(id_post) FROM comments WHERE id_post = '". $row["id"]."' ");  
  2. // it works if I do this: echo mysql_result($numComents,0);
  3.        
  4. if ($numComments > 0){
  5.     echo mysql_result($numComments,0);
  6. }else{
  7.  
  8. }
  9.        
  10. $result = mysql_query("SELECT COUNT(id_post) FROM comments WHERE id_post = '". $row["id"]."' ");
  11. $numComments = mysql_result($result,0);
  12. if ( $numComments  > 0) {
  13.  echo $numComments ;
  14.  } else {
  15.    //do something...
  16.  }
  17.        
  18. $number_of_rows = mysql_fetch_row($numComments)[0];
  19.  
  20. echo $number_of_rows > 0 ? $number_of_rows : '';
RAW Paste Data
Top