mirror of
https://git.code.sf.net/p/quake/website
synced 2025-04-08 00:30:59 +00:00
display up to 5 news items rather than 1 month's worth
This commit is contained in:
parent
1375d15761
commit
cabc4b88ac
2 changed files with 3 additions and 4 deletions
|
@ -11,7 +11,7 @@
|
|||
tableBoxHeader (featureBgColor, featureHeadColor);
|
||||
tableTitle ('Latest News', 1, featureHeadColor);
|
||||
need ("news");
|
||||
$cached = latestNews ('1 month');
|
||||
$cached = latestNews (5);
|
||||
tableBoxFooter ();
|
||||
?></TD>
|
||||
</TR>
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue