View file index.php

File size: 2.23Kb
<?php
include 'ini.php';if ($html) echo '<div class="sec">';echo 'Новости';
if($html) echo '</div>';
else
echo '<br/>----<br/>';

// --------------------------------------------------------------------------------------------------------------------
$q = mysql_qw ('SELECT * FROM news ORDER BY time DESC');
if(mysql_num_rows($q)==0)
{	if($html) { echo '<div>'; $dive =  '</div>'; } exit ('[Новостей нет]'.$dive.$px);
}
for($list = array(); $qw = mysql_fetch_array ($q); $list[] = $qw);
$all = count ($list);
$pages = ceil($all/$onpage);
if (!$pages) $pages =1;
if(!$page) $page = 1; else $page = intval ($page);

$pager = '';

if ($html) $pager = '<div class="sec">';
$pager .= "Страница: $page из $pages<br/>";
if($page>1)  $pager .="<a href='index.php?wap=$wap&amp;page=".($page-1)."'>Пред</a>"; else $pager .= "Пред";
$pager .=" | ";
if($page<$pages)$pager .= "<a href='index.php?wap=$wap&amp;page=".($page+1)."'>След</a>"; else $pager .= "След.";
$pager .= "<br/>";
if($pages>2)
{
if ($html)
$pager .= "<form action='index.php?wap=$wap' method='post'>
Перейти на <input name='page' size='2'><input type='submit' value='Стр.'></form>";
else
$pager .= "Перейти на:<input name='page' size='2'/><a href='index.php?wap=$wap&amp;page=$(page)'>Стр.</a>";
$pager .= "<br/>";}

// ----------------------------------------------------------------------------------------------------
$n = 0;
$n = ceil ($page*$onpage)-$onpage;
$div = '';
$dive = '<br/>';
$br = '<br/>----<br/>';if($html)
{$div = '<div class="news">';
$dive = '</div><div>';
$br = '</div>';
}
for ($i=$n; $i<=$n+$onpage-1; $i++)
{$link = '';
if($pass == $admin) $link = "[<a href='admin.php?pass=$pass&amp;edit=".$list[$n]['id']."'>*</a>][<a href='admin.php?pass=$pass&amp;del=".$list[$n]['id']."'>X</a>]";if(!isset($list[$n])) continue;
$ct = mysql_qw ('SELECT COUNT(*) FROM comm WHERE id_news=?',$list[$n][id]);
$ct = mysql_fetch_array ($ct); $ct = $ct[0];
echo $div.rudate("d m",$list[$n]['time']).$link.$dive.show($list[$n]['news'])."<br/><a href='comm.php?wap=$wap&amp;id=".$list[$n][id]."'>Мнения[$ct]</a>".$br;
$n++;
}

echo $pager."";
if ($html) echo "</div>"; else echo '----';





exit ($px);
?>