rendered paste body<?php
$mysql_table = "cp_news";
$com_table = "cp_comments";
require_once ("required.inc.php");
getHeader();
if (!$_REQUEST[s]) {
$s = 0;
$result = MYSQL_QUERY("SELECT * FROM $mysql_table ORDER BY topic_id DESC LIMIT $max_news") or die (mysql_error());
} else {
$s = $_REQUEST['s'];
$result = MYSQL_QUERY("SELECT * FROM $mysql_table ORDER BY topic_id DESC LIMIT $max_news, $s") or die (mysql_error());
}
$count = MYSQL_QUERY("SELECT * FROM $mysql_table") or die (mysql_error());
$rows = mysql_num_rows($count);
if ($rows == "0") {
echo "
<h2>no news!</h2>
<p>There are no news items</p>
";
} else {
while ($mysql=mysql_fetch_array($result)) {
$res = mysql_query("select count(*) from $com_table where topic_id = {$mysql[topic_id]}");
$count = 0;
if (list($c) = mysql_fetch_array($res)) $count = $c;
echo "<h2>" . checkContent($mysql[news_topic]) . "<font class=\"date\">" . $mysql[topic_date] . "</font><br /></h2>
<p><span class=\"poster\">Posted by: " . checkContent($mysql[news_author]) . "</span><br />
" . checkContent($mysql[news_message]) . "
</p><br />
";
$pref = ($count != 1 ? 's' : '');
if ($mysql[comments_enabled] == 1) { # comments enabled
echo "<p class=\"comments\">$count Comment{$pref} - <a href=\"viewnews.php?id={$mysql[topic_id]}\">View/Add Comments</a></p>";
}
elseif ($mysql[comments_enabled] == 0 && $count > 0) { # comments locked
echo "<p class=\"comments\">$count Comment{$pref} - <a href=\"viewnews.php?id={$mysql[topic_id]}\">View Comments</a></p><div id=\"contentFt\"></div>";
}
else { } # comments disabled
}
}
getFooter();
?>