. **/ if(isset($_GET['posts_offset']) && isset($_GET['posts_limit'])){ $sql=$db->prepare("SELECT b.id, b.title, u.fullname AS owner, b.date, b.content, GROUP_CONCAT(bt.tag SEPARATOR ';') AS tags FROM blog AS b INNER JOIN users AS u ON (u.id=b.owner) LEFT JOIN blog_tags AS bt ON (bt.blogentry=b.id) WHERE b.published=1 GROUP BY b.id ORDER BY b.date DESC LIMIT :lim OFFSET :off"); $sql->execute(array(":lim"=>$_GET['posts_limit'], ":off"=>$_GET['posts_offset'])); $blog=array(); while($row=$sql->fetch(PDO::FETCH_ASSOC)){ array_push($blog, json_encode($row)); } echo json_encode($blog); die(); } if(isset($_GET['posts_tag']) && isset($_GET['posts_tag_offset']) && isset($_GET['posts_tag_limit'])){ $sql=$db->prepare("SELECT b.id, b.title, u.fullname AS owner, b.date, b.content, GROUP_CONCAT(bt.tag SEPARATOR ';') AS tags FROM blog AS b INNER JOIN users AS u ON (u.id=b.owner) LEFT JOIN blog_tags AS bt ON (bt.blogentry=b.id) WHERE b.published=1 and bt.tag=:tag GROUP BY b.id ORDER BY b.date DESC LIMIT :lim OFFSET :off"); $sql->execute(array(":tag"=>$_GET['posts_tag'], ":lim"=>$_GET['posts_tag_limit'], ":off"=>$_GET['posts_tag_offset'])); $blog=array(); while($row=$sql->fetch(PDO::FETCH_ASSOC)){ array_push($blog, json_encode($row)); } echo json_encode($blog); die(); } if(isset($_GET['post'])){ $sql=$db->prepare("SELECT b.id, b.title, u.fullname AS owner, b.date, b.content, GROUP_CONCAT(bt.tag SEPARATOR ';') AS tags FROM blog AS b INNER JOIN users AS u ON (u.id=b.owner) LEFT JOIN blog_tags AS bt ON (bt.blogentry=b.id) WHERE b.published=1 and b.id=:id GROUP BY b.id ORDER BY b.date DESC"); $sql->execute(array(":id"=>$_GET['post'])); $res=$sql->fetch(PDO::FETCH_ASSOC); echo json_encode($res); die(); }