<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle(homeurl.' - Новости');
$title->GetHeader();
//echo'<div class="row"><div class="col-sm-6">';
$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM news");
if ($look ==0) {
err('Новостей нет!');
} else {
$num = 5;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
$sql = DB::$dbs->query("SELECT * FROM news ORDER BY time DESC LIMIT $start,$num");
while($a = $sql->fetch()) {
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: '.$a['name'].' ('.vr($a['time']).')</div></div></div>';
echo '<div class="list-group-item media"><div class="media-body"><div class="list-group-item-heading">'.text($a['txt']).'<br/>Автор: '.Nick($a['user']).'<br/><a href="comm.html?id='.$a['id'].'"><i class="zmdi zmdi-comment"></i> Комментарии</a> ('.DB::$dbs->querySingle("SELECT COUNT(id) FROM news_comm WHERE id_news = ?", [$a['id']]).') </div></div></div>';
}
}
if ($k_page>1) {
str('?', $k_page,$page);
}

$title->GetMenu();
$title->GetFooter();
?>