<?php

$post = trim($_GET['post']);

if ($post) {

   mysql_connect('localhost','nazwa_uzytkownika','haslo');
   mysql_select_db('baza_danych');

   $rows = mysql_query("SELECT comment_ID,comment_author,comment_content from wp_comments where comment_post_ID = '$post' and comment_approved = '1' order by comment_ID");
   if ($rows && mysql_num_rows($rows) > 0) {
      $str = "[";
      while($row = mysql_fetch_row($rows)) {
         if ($str != '[') $str.=",";
         $str.= "{ id : '$row[0]', autor : '$row[1]', treć : \"$row[2]\" }";
      } 
      $str.="]";
   }
   echo $str;       
} else {
   echo "Brak wpisów";
}
?> 
