Файл: news.php
Строк: 32
<?php
require 'sys/sid.php';
require 'sys/config.php';
include 'sys/user.php';
include 'sys/head.php';
include 'sys/navigator.php';
visit(0, 'news');
$q = isset($_GET['q']) ? $_GET['q'] : NULL;
switch($q)
{
default:
$COUNT = mysql_result(mysql_query("SELECT COUNT(*) FROM news"), 0);
if ($COUNT != 0)
{
$n = new navigator($COUNT, 5, 'nnews&');
$sql = mysql_query("SELECT id, name FROM news ORDER BY id DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($sql))
{
$counter = (++$i + $n->start);
echo $counter . '. <a href="viewnew'.$a['id'].'">' . $a['name'] . '</a><br/>';
}
echo $n->navi();
} else echo 'Новостей нет.<br/>';
break;
case view:
$id = number($_GET['id']);
$control = mysql_query("SELECT * FROM news WHERE id = '$id' LIMIT 1");
if (mysql_num_rows($control) == false)
{
err('Новости не существует!');
}
else
{
$a = mysql_fetch_assoc($control);
echo '<b>' . $a['name'] . '</b><br/><br/>' . smiles($a['text'], 0);
}
echo '<br/><br/><a href="news.php">Вернуться</a>';
break;
}
echo '<br/><a href="/">На главную</a>';
include 'sys/foot.php';
?>