From cabc4b88acb08ec0da0bd98ef5baa6f5511029f8 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 19 Feb 2002 21:52:02 +0000 Subject: [PATCH] display up to 5 news items rather than 1 month's worth --- index.php | 2 +- lib/news.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index e2700d8..2232ab1 100644 --- a/index.php +++ b/index.php @@ -11,7 +11,7 @@ tableBoxHeader (featureBgColor, featureHeadColor); tableTitle ('Latest News', 1, featureHeadColor); need ("news"); - $cached = latestNews ('1 month'); + $cached = latestNews (5); tableBoxFooter (); ?> diff --git a/lib/news.php b/lib/news.php index 9cee8dc..8935b88 100644 --- a/lib/news.php +++ b/lib/news.php @@ -163,19 +163,18 @@ return 0; } - function latestNews ($length) + function latestNews ($max) { if (sqlAvail) { $conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass); if ($conn) { $query = 'SELECT n_date, n_user, n_news FROM news_main' . - " WHERE n_date > DATE_SUB(NOW(), INTERVAL $length)" . ' ORDER BY n_date DESC'; $result = @mysql_db_query (sqlDB, $query, $conn); if ($result) { $numRows = @mysql_num_rows ($result); if ($numRows) { - for ($i = 0 ; $i < $numRows ; $i++) { + for ($i = 0 ; $i < $numRows && $i < $max; $i++) { $news[$i] = mysql_fetch_array ($result); echo newsEntry ($news[$i]); }