Tutorials Infos - Anleitungen - Hilfe - Dreamcodes
 

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>';
?>

 
ID: 439
eingestellt am: 04.07.2004
Autor: slave
Status zum lesen: Gast
gelesen: 8054
Webseite: www.dreamcodes.com
[Drucken]