<?PHP include('header.php'); 
$kolvo = "10"; //кол-во выводимых новостей на странице
$allnews=mysql_num_rows(mysql_query("SELECT `id` FROM `b_news`")); //общее кол-во новостей
$vsego=intval($allnews/$kolvo);
if($vsego == "0") $vsego = "1";
$nowpage = (isset($_GET["pg"])) ? intval($_GET["pg"]) : NULL;
if($nowpage == '' or $nowpage <= "0") $nowpage = "1";
if($nowpage-1>$vsego) $nowpage=$vsego;
if(!isset($_GET["pg"])) $nowpage = "1";
$gg = $vsego * $kolvo;
if($gg < $allnews) { $vsego = $vsego + 1; }
$pages = $vsego/$kolvo;
$pages1 = floor($pages);
$pg1 = $kolvo * ($nowpage - 1);
$pg2 = $kolvo;
if($nowpage == $vsego) { $pg1 = "0"; $pg2 = $kolvo; }
if($pages > $pages1) $pages = $pages1+1;

$nextp = $nowpage + 1;
$lastp = $nowpage - 1;

$res = mysql_query("SELECT * FROM `b_news` ORDER BY `id` DESC LIMIT $pg1,$pg2") or die(mysql_error());
echo "
<span class='top-bl-s-verh'>Форум проекта WM Rush</span>
<div class='menucenter-top1'>
<table class='profile' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 0;'>
<tr><td class='value1'>
Все новости проекта
</td></tr>
</table>
<table width='100%' style='margin-bottom: 5px;'>
 <tr>
	<td nowrap='nowrap'>";
if($nowpage <> 1) { echo "<a href='/news-page-$lastp'><span class='text14'>"; }else{ echo "<span class='textgray'>"; } echo "Предыдущие</span>";if($nowpage==1) { echo "</a>"; } echo "</td>
	<td width='90%' align='center'>Страница $nowpage из $vsego</td>
	<td nowrap='nowrap'>";
if($nowpage==$vsego){ echo "<span class='textgray'>"; }else{ echo "<a href='/news-page-$nextp.php'><span class='text14'>"; } echo "Следующие</span>"; if($nowpage==$vsego) { echo "</a>"; } echo "</td>
 </tr>
</table>";

if(mysql_num_rows($res) > 0) echo "<table class='news' width='100%' border='0' cellpadding='0' cellspacing='0'>";
while ($row = mysql_fetch_assoc($res)){
$row["newstext"]=nl2br(bbcode($row["newstext"],"html"));
	echo "<tr><td class='messtitle'>";
	echo $row["data"]."</td>";
	echo "</tr><tr>";
	echo "<td valign='top' style='border: none;'><div class='fmessage'><span class='newstitle'>";
	echo $row["tema"]."<br /></span>".$row["newstext"]."</div>";
$nid=$row["id"];
$re=mysql_query("select count(*) AS `kolvo` FROM `b_news_comm` WHERE `idnew`='$nid'");
$re=mysql_fetch_array($re);
$allcomments=$re["kolvo"];
echo "<br /><a class='fbtn-blue160' href='/forum_post_".$row["forum"]."'>Обсудить</a></td></tr>";
}
if(mysql_num_rows($res) > 0) echo "</table>";
echo "</div>";
include('footer.php');?>