Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 14th, 2013  |  syntax: None  |  size: 0.56 KB  |  views: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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 : '';