display up to 5 news items rather than 1 month's worth

This commit is contained in:
Bill Currie 2002-02-19 21:52:02 +00:00
parent 1375d15761
commit cabc4b88ac
2 changed files with 3 additions and 4 deletions

View file

@ -11,7 +11,7 @@
tableBoxHeader (featureBgColor, featureHeadColor);
tableTitle ('Latest News', 1, featureHeadColor);
need ("news");
$cached = latestNews ('1 month');
$cached = latestNews (5);
tableBoxFooter ();
?></TD>
</TR>

View file

@ -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]);
}