Файл: news.php
Строк: 25
<?php
require('core/start.php');
$data_head = array(
'title' => lang('news')
);
head($data_head);
$count = mysqli_fetch_row(mysqli_query($db, "SELECT COUNT(*) FROM files"));
$total = $count[0];
$perpage = 1;
$count_pages = ceil($total / $perpage);
if (!$count_pages) {
$count_pages = 1;
}
if (!empty($_GET['page'])) {
$page = abs((int)$_GET['page']);
if (!$page) {
$page = 1;
}
} else {
$page = 1;
}
if ($page > $count_pages) {
$page = $count_pages;
}
$start_pos = ($page - 1) * $perpage;
$pagenation = pagenation($page, $count_pages);
$query = "SELECT * FROM news order by id desc LIMIT $start_pos, $perpage";
$result = mysqli_query($db, $query);
while ($data = mysqli_fetch_array($result)) {
echo '<div class="novosti"><b>', $data['date'], '</b><br />', nl2br(htmlspecialchars_decode($data['text'])), '</div>';
}
if (!empty($pagenation)) {
echo $pagenation;
}
?>
<div class="link"><a href="<?= HOME ?>"><?= lang('home') ?></a></div>
<?php
footer();