datum en tijd bij laatste 5 topics

Hulp nodig bij een modificaties of op zoek naar een MOD? Bekijk ons archief. Support wordt helaas niet meer verleend.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
BoGhy
Berichten: 2
Lid geworden op: 05 jan 2007, 22:33

datum en tijd bij laatste 5 topics

Bericht door BoGhy » 06 jan 2007, 00:14

hey allemaal,

ik heb een tijdje geleden de volgende code gevonden:

Code: Selecteer alles

<? 
#database info, or include a config.php file
$db_host = 'localhost'; #change to your host
$db_user = 'username'; #change to your user name
$db_password = 'password'; #change to your password
$db_name = 'db name'; #change to your db name

mysql_connect($db_host,$db_user,$db_password) or die(mysql_error()); 
mysql_select_db($db_name) or die(mysql_error()); 

/* To keep a forum secret (i.e. a mods only forum) find, AND t.forum_id != 1
   and change 1 to the forums id (according to your database). To select a specific forum (i.e. news forum)
   find AND t.forum_id != 1, and change it to t.forum_id = 1 (where 1 = the forums id) */
$result = mysql_query("SELECT DISTINCT t.topic_id, t.topic_title, t.topic_replies, u.user_id, u.username, s.post_text
FROM phpbb_posts p, phpbb_topics t, phpbb_users u, phpbb_posts_text s
WHERE p.topic_id = t.topic_id AND t.topic_poster = u.user_id AND t.topic_first_post_id = s.post_id AND t.forum_id = 1 AND u.user_id != -1
ORDER BY p.post_time DESC LIMIT 10");

/* This function is used to limit the amount of text displayed, as well as replace any bbcode.
   it also converts any new lines (enters/returns), to an acctual break for people to see
   if you want bbcode displayed, remove the $text = preg_replace... line.
   This is only needed if you want to post the body text of a post */
   function text($text, $limit){
    $text = str_replace("\n", "<br>", $text);
    $text = preg_replace("#\[(.*?)\].*?\[/(\\1)\]#si", "<i>[bbcode]</i>", $text);
    if(strlen($text)>$limit){
        $text = substr($text, 0, $limit);
        $text = substr($text, 0, -(strlen(strrchr($text, ' '))))."...";
    }
    return $text;
}

   
while($r=mysql_fetch_array($result)){ 
/* Change 100, to the number of characters you want to show.
   If you didn't keep the above text() function, then change the following line to:
   $text = $r['post_text']; */
$text = text($r['post_text'], 300);

/* To change the display, edit this.
   Also change both the <a> tags to the correct path to your forums, leave the part after /forum/ the same */
echo "{$r['topic_title']}<br>
<br>$text<br>
<br> "datum en tijd" <a href=\"/forum/viewtopic.php?t={$r['topic_id']}\" target=\"_blank\">{$r['topic_replies']} Reacties</a> <a href=\"/forum/viewtopic.php?t={$r['topic_id']}\" target=\"_blank\">Lees verder...</a><br>
<hr>"; 
} 
?> 
nu wil ik graag op de plek: "datum en tijd" de datum en tijd van wanneer het topic is aangemaakt. bijvoorbeeld: 05/01/07 | 23.35

ik weet alleen niet hoe, dus ik hoop dat één van jullie mij kan helpen

alvast bedankt

BoGhy
Berichten: 2
Lid geworden op: 05 jan 2007, 22:33

Bericht door BoGhy » 08 jan 2007, 16:32

ik heb inmiddels nu de datum in beeld, maar nu staat bij elke onderwerp dat het bericht geplaatst is op 01/01/1970 om 01:01. ik denk dat er een fout zit in de volgende code, maar ik weet niet waar:

Code: Selecteer alles

<? 
#database info, or include a config.php file
$db_host = 'localhost'; #change to your host
$db_user = 'username'; #change to your user name
$db_password = 'password'; #change to your password
$db_name = 'db name'; #change to your db name

mysql_connect($db_host,$db_user,$db_password) or die(mysql_error()); 
mysql_select_db($db_name) or die(mysql_error()); 

/* To keep a forum secret (i.e. a mods only forum) find, AND t.forum_id != 1
   and change 1 to the forums id (according to your database). To select a specific forum (i.e. news forum)
   find AND t.forum_id != 1, and change it to t.forum_id = 1 (where 1 = the forums id) */
$result = mysql_query("SELECT DISTINCT t.topic_id, t.topic_title, t.topic_replies, u.user_id, u.username, s.post_text, `t`.`topic_time`
FROM phpbb_posts p, phpbb_topics t, phpbb_users u, phpbb_posts_text s
WHERE p.topic_id = t.topic_id AND t.topic_poster = u.user_id AND t.topic_first_post_id = s.post_id AND t.forum_id = 5 AND u.user_id != -1
ORDER BY p.post_time DESC LIMIT 5");

/* This function is used to limit the amount of text displayed, as well as replace any bbcode.
   it also converts any new lines (enters/returns), to an acctual break for people to see
   if you want bbcode displayed, remove the $text = preg_replace... line.
   This is only needed if you want to post the body text of a post */
   function text($text, $limit){
    $text = str_replace("\n", "<br>", $text);
    $text = preg_replace("#\[(.*?)\].*?\[/(\\1)\]#si", "<i>[bbcode]</i>", $text);
    if(strlen($text)>$limit){
        $text = substr($text, 0, $limit);
        $text = substr($text, 0, -(strlen(strrchr($text, ' '))))."...";
    }
    return $text;
}

   
while($r=mysql_fetch_array($result)){ 
/* Change 100, to the number of characters you want to show.
   If you didn't keep the above text() function, then change the following line to:
   $text = $r['post_text']; */
$text = text($r['post_text'], 300);

/* To change the display, edit this.
   Also change both the <a> tags to the correct path to your forums, leave the part after /forum/ the same */
echo "<br>{$r['topic_title']}<br>
<br>$text<br>
<br> ".date("d/m/Y | h:m",$topic_time)." | <a href=\"/forum/viewtopic.php?t={$r['topic_id']}\" target=\"_blank\">{$r['topic_replies']} Reacties</a> | <a href=\"/forum/viewtopic.php?t={$r['topic_id']}\" target=\"_blank\">Lees verder...</a><br>
<hr>"; 
} 
?> 
kan iemand mij helpen?

Gesloten