News auslesen
In einem phpbb-Forum hat man öfters ein Forum 'News' diese
Einträge kann man mit dem Schnipsel auch auf der Hauptseite anzeigen.
|
Script: |
<?php
//Klasse
class phpbbnews{
var $forumId
=
0;
var $forumpre =
"phpbb_";
function getNewsOverview($limit
= "0,
4", $days
= 100){
$forumpre
= $this->forumpre;
$forumId =
$this->forumId;
$sql
= "
SELECT
".$forumpre."topics.topic_id
AS
Id,
".$forumpre."topics.forum_id,
".$forumpre."topics.topic_title
AS title
FROM
".$forumpre."topics
WHERE
".$forumpre."topics.forum_id
= $forumId
AND
".$forumpre."topics.topic_time
> UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $days DAY))
ORDER
BY
".$forumpre."topics.topic_time
DESC
LIMIT
$limit
";
$result
= mysql_query($sql);
return $result;
}
}
//Beispiel
$news =
new phpbbnews();
$news->forumId
= 9;
$news->forumpre
= "for_";
echo '<table
style="width:100%;" cellspacing="0"
cellpadding="0">';
$result =
$news->getNewsOverview();
while($row =
mysql_fetch_array($result,
MYSQL_ASSOC)){
echo '
<tr>
<td
style="text-align:center;">
<a
href="/forum/viewtopic.php?t='.$row["Id"].'">'.$row["title"].'</a>
</td>
</tr>';
}
echo '</table>';
?>
|
|