<?php

$count = mysqli_num_rows(mysqli_query($mysqli,"SELECT * FROM `top_news`"));
		if($count > 0)
			{
				$total=intval(($count-1)/$page_news)+1; 
				$page=abs(intval($_GET['page'])); 
				if(empty($page) OR $page < 0)
					{
						$page = 1; 
					}
				if($page > $total)
					{
						$page = $total; 
					}
				$past=intval($count/$page_news);  
				$start=$page*$page_news-$page_news; 
				$news = mysqli_query($mysqli,"SELECT * FROM `top_news` ORDER BY `time` DESC LIMIT 1");
				while($row = mysqli_fetch_array($news)) 
					{

					
					
						$start++;
						$count_comment = mysqli_num_rows(mysqli_query($mysqli,"SELECT * FROM `top_news_comments` WHERE `id_news` = '".$row['id']."'"));
						echo '<div class="topni"><font color="red"><b><u>'.$row['name'].'</u></b></font><span class="cat_count">'.data($row['time']).'</span></br>';
					
						echo ''.$row['text'].'<br/>';
						echo '<hr/>';
						echo 'Автор: <b>'.$row['author'].'</b>';
						echo '<span class = "cat_count" style="float:right"><a style="margin-right: 9px"><a href="/m/news/comments/'.$row['id'].'">Комментарии</a> ['.$count_comment.']</span>';
						
						echo '</b></div>';
						}	
				
				
			}
		else
			{
				echo '<div class="topni">Новостей в Топ-Рейтинге нет!<br/></div>';
			}

?>