Hoe moet ik in deze PHPBB Active Topic script de User Functie en de Time Functie zetten
(door wie het gepost is en hoelaat)
Voorbeeld

13:04       Blablablabla         Door Erkan


Hier is de script waar het in moet:

<?php
$limit = 7; // Hoeveel wil je er showen? 
$forumpad = "forum"; //Pad naar forum (zonder slash erachter!) 

include_once ("".$forumpad."/config.php"); 

mysql_connect($dbhost,$dbuser,$dbpasswd) or die(mysql_error()); 
mysql_select_db($dbname) or die(mysql_error()); 

$sql = "SELECT * FROM phpbb_topics ORDER BY topic_last_post_id DESC LIMIT 0,$limit"; 
$query = mysql_query($sql) or die(mysql_error()); 

while($rij = mysql_fetch_object($query)) 
{ 
    echo "<a href=\"$forumpad/viewtopic.php?p=$rij->topic_last_post_id#$rij->topic_last_post_id\">$rij->topic_title</a><br>"; 
} 
?> 
<?php
$limit = 7; // Hoeveel wil je er showen?
$forumpad = "forum"; //Pad naar forum (zonder slash erachter!)

include_once ($forumpad."/config.php");

mysql_connect($dbhost,$dbuser,$dbpasswd) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$sql = "SELECT * FROM phpbb_topics ORDER BY topic_last_post_id DESC LIMIT 0,$limit";
$res = mysql_query($sql) or die(mysql_error());

while($rij = mysql_fetch_assoc($res))
{
echo 'Gepost om '.$rij['tijd_van_laatste_post'].' door '.$rij['naam_van_auteur_van_laatste_post'].': <a href="'.$forumpad.'/viewtopic.php?p='.$rij['topic_last_post_id'].'#'.$rij['topic_last_post_id'].'">'.$rij['topic_title'].'</a><br />';
}
?>
Verder gebruik beter foutafhandeling.

Zoals dit:



<?php
$sql = "SELECT id,naam FROM tabel;"; //simpele SQL die de kolommen "id" en "naam" ophaalt uit de tabel "tabel"

if (! $res = mysql_query($sql)) //als de query FALSE terug geeft, geef dan foutmelding:
{
    ?>
    <br />
    Er ging iets fout. Dit is de gebruikte SQL: <br />
    <pre><?php echo $sql; ?></pre>
    <br />
    Deze fout meldde mysql: <br />
    <pre><?php trigger_error(mysql_errno()); ?>: <?php trigger_error(mysql_error()); ?></pre>
    <br />
    <?php 
}
else //als de query iets anders dan FALSE terug geeft (TRUE dus), gaan we door:
{
    if (mysql_num_rows($res) > 0) //controleren of er wel resultaten zijn:
    {
        while ($rij = mysql_fetch_assoc($res)) //in een loop de resultaten echo-en
        {
            ?>
            Nummer <?php echo $rij['id']; ?> heeft als naam <?php echo $rij['naam']; ?>. <br />
            <?php
        }
    }
    else //als er geen resultaten zijn geven we dat weer:
    {
        ?>
        <span style="font-style: italic;">Geen resultaten. </span>
        <?php
    }
}
?>

Bestaat al een topic over.

Reageren