Last active
December 20, 2015 14:28
-
-
Save c01nd01r/6146295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// | |
// Код для разбивки контента на страницы взят отсюда: http://forum.php.su/topic.php?forum=1&topic=6985 | |
// | |
$result = $GLOBALS['db']->Query("SELECT * FROM " . PREFIX . "_modul_contact_info"); | |
$rows_max = $result->NumRows(); // Сколько всего заявок с формы в базе | |
$show_pages = 5; // Сколько заявок с формы покажем пользователю | |
$this_page = filter_var($_GET['page'], FILTER_SANITIZE_NUMBER_INT); // Номер текущей страницы | |
if ($this_page) | |
{ | |
$offset = (($show_pages * $this_page) - $show_pages); | |
} | |
else | |
{ | |
$this_page = 1; // Ставим в единицу (первая страница) если не передан параметр $_GET['page'] | |
$offset = 0; | |
} | |
if ($rows_max > $show_pages) | |
{ // Панелька с навигацией по страницам | |
$r = 1; | |
while ($r <= ceil($rows_max/$show_pages)) | |
{ | |
if ($r != $this_page) | |
{ | |
echo '<a href="?page=' . $r . '" title="Перейти на страницу '.$r.'">'.$r.'</a>' ; | |
} | |
else | |
{ | |
echo '<b>' . $r . '</b>'; // Если это текущая страница - то ссылка на саму себя не нужна | |
} | |
$r++; | |
} | |
} | |
$lim = $offset.", ".$show_pages; // Запутался в кавычках :\ | |
$final_result = $GLOBALS['db']->Query("SELECT * FROM " . PREFIX . "_modul_contact_info ORDER BY Id DESC LIMIT ".$lim." "); | |
while ($row = $final_result->fetchrow_assoc()) { //Вывод контента на страницу | |
echo '<center><div id="novosti"><table border="0" width="706"><td><strong><center> <div id="novostin"><div id="novostip">'.$row["name"].'</a><br /></div><hr></hr></center></strong><div id="novostit">' ; | |
echo $row["text"].'</div><div id="novostif"><br /></div></div></td></table></div><br />' ; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment