function selectPage() { $page = 'posts/home.md'; // le load pardefaut if (isset($_GET['page'])) { // c'est pour voir si $_GET 'page' renvoi quelque chose , si oui on l'assigne a la variable page $page = $_GET['page']; } return loadPost($page); }
$query = mysql_query("SELECT `id`,`title`,`date`,`text` FROM `post` ORDER BY `id` DESC"); //Отключаемся от БД mysql_close($DBC); //Проверяем, есть ли, что грузить if ((int) $_POST['count_show'] >= $hmp) { echo json_encode(array('result' => 'finish')); exit; } //Переменные $min = (int) $_POST['count_show']; if ($min + $pop > $hmp) { $max = $hmp; } else { $max = $min + $pop; } //Функция загрузки поста function loadPost($query, $i) { global $html; global $url; $id = mysql_result($query, $i, 'id'); $title = mysql_result($query, $i, 'title'); $date = mysql_result($query, $i, 'date'); $text = htmlspecialchars_decode(mysql_result($query, $i, 'text'), ENT_QUOTES); $html .= "<div class=\"post\">\n <div class=\"title\"><a href=\"{$url}/post.php?id={$id}\">{$title}</a></div>\n <div class=\"date\">{$date}</div>\n <div class=\"text\">{$text}</div>\n </div>\n </div>"; } //Формируем ответ for ($i = $min; $i < $max; $i++) { loadPost($query, $i); } echo json_encode(array('result' => 'success', 'html' => $html));