Edited by zasul, 12 July 2005 - 12:19 PM.
need HELP >>> pls
Started by zasul, Jul 12 2005 12:16 PM
3 replies to this topic
#1
Posted 12 July 2005 - 12:16 PM
im starting a version 3 of http://www.dumb-design.tk and if anyone could help me ... i need a show last 10-5 forum post script ...preferable phpbb... pls help I cant launch the site because of this small thingie
#2
Posted 12 July 2005 - 01:54 PM
i actually found this on a site a couple hours ago
<?
#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 = 'database_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 != 6, and change 6 to the forums id (according to your database)
to select a specific forum (i.e. news forum), find AND t.forum_id != 6, and change it to t.forum_id = *the forums id* */
$result = mysql_query("SELECT DISTINCT t.topic_id, t.topic_title, t.topic_poster, t.topic_first_post_id, t.forum_id, t.topic_replies, u.user_id, u.username, s.post_id, 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 != 6 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
ONLY KEEP IF YOU ARE GOING TO DISPLAY THE BODY TEXT OF A POST */
function text($text, $limit){
$text = str_replace("\n", "<br>", $text);
$text = preg_replace("#\[(.*?)\].*?\[/(.*?)\]#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
you only need the following line if you kept the above function */
$text = text($r['post_text'], 100);
/* 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 "<a href=/forum/viewtopic.php?t=".$r['topic_id']." target=_blank>".$r['topic_title']."</a><br>
by: <a href=/forum/profile.php?mode=viewprofile&u=".$r['user_id']." target=_blank>".$r['username']."</a><br>
$text
<div align=\"right\">Replies: ".$r['topic_replies']."</div>
<hr>";
}
#OPTIONAL, to save file size, delete the orange comments
?>
Edited by Sk8erGuy, 12 July 2005 - 01:54 PM.
#3
Posted 13 July 2005 - 01:14 AM
If you need any help with that code, it actually came from my site 
http://forum.decepti...ewforum.php?f=8 <-- support forum (no registration needed).
As you could tell simply by looking at that page, theres quite a few errors i need to work out with that.
http://forum.decepti...ewforum.php?f=8 <-- support forum (no registration needed).
As you could tell simply by looking at that page, theres quite a few errors i need to work out with that.
#4
Posted 14 July 2005 - 12:20 AM
ahh thank you. i would have mentioned your site but i only had that script copied to my clipboard. couldnt remember url
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
