<?php

$start = $_REQUEST['start'];
$limit = $_REQUEST['limit'];
$callback = $_REQUEST['callback'];

if (empty($start)) {
   $limitstr = "limit $limit";
} else {
   $limitstr = "limit $start,$limit";
}
mysql_connect('localhost','nazwa_uzytkownika','haslo');
mysql_select_db('baza_danych');

$rows = mysql_query("SELECT ID, post_title, guid, comment_count from wp_posts order by ID $limitstr");
if ($rows && mysql_num_rows($rows) > 0) {
   $str = "[";
   while($row = mysql_fetch_row($rows)) {
      if ($str != '[') $str.=",";
      $str.= "{ id : '$row[0]', tytuł : \"$row[1]\", guid : '$row[2]', komentarze: '$row[3]' }";
   } 
   $str.="]";
}
echo $callback . '(' . $str . ')';
?> 
