<?php
$IN_ENGINE = true;
$show_menu = true;
require_once("includes/dbconnect.php");
require_once("includes/preprocessing.php");
require_once("includes/functions.php");
require_once("template/header.php");


$content = "";

if (isset($_GET['id'])) {
$number = intval($_GET['id']);

$query = mysql_query("SELECT * FROM dgh_news WHERE nid = '".$number."'");
$query = mysql_fetch_array($query);

echo "<table cellpadding='0' cellspacing='0' border='0' class='cont_header_txt'><tr><td>".$query['title']."</td></tr></table>";

$content .= stripslashes($query['text']);
$content .= "<br>[ <a href='news.php'>назад</a> ]";

$style_padding = 15;
include("template/table_content.php");

} else {

echo "<table cellpadding='0' cellspacing='0' border='0' class='cont_header_txt'><tr><td>Новости</td></tr></table>";

$content .= "<table cellpadding='0' cellspacing='0' width='100%'>\n";

$query = mysql_query("SELECT * FROM dgh_news ORDER BY date DESC");

$i = 1;
while($result = mysql_fetch_array($query)) {
	$content .= "<tr><td>";
	$content .= date("d.m.Y", $result['date']);
	$content .= "<br><a href='?id=".$result['nid']."'>".$result['title']."</a><br><br>";
	$content .= "</td></tr>";
	
	$i++;
}

if ($i == 1) $content .= "<tr><td align='center'><u>Новостей не найдено</u></td></tr>";

$content .= "</table>\n";

$style_padding = 15;
include("template/table_content.php");

}


require_once("template/footer.php");
?>