latest posts

sboulema

OSNN Veteran Addict
Joined
19 Jun 2002
Messages
2,846
Im making a invision forum and i wanna know how i can get a list of the latest 5 post on my site.

im a complete php newbie, so please be very clear. Hope you guys can help me.
 
Make a new file or function with the foillowing content:

Code:
$recentforumget = 5; // Number of posts to get
$recentforumlength = 30; // Length of title to display before cutting off
$forumexclude = ""; // Add forum id's to exclude from get (eg private ones) sepetate by a comma

$getposts = query("SELECT tid,title,forum_id FROM ".$ibf_prefix."topics WHERE  (state <> 'link')".iif($forumexclude," AND (forum_id NOT IN ($forumexclude))")." ORDER BY last_post DESC LIMIT $recentforumget");

while ($post = fetch_array($getposts)) {
$post[short_title] = iif(strlen($post[title]) > $recentforumlength,substr($post[title],0,$recentforumlength)."...",$post[title]);
$post[full_title] = $post[title];
$recentforumposts .= "<a href=\"$forumpath/index.php?act=ST&f=$post[forum_id]&t=$post[tid]\" title=\"$post[full_title]\">$post[short_title]</a><br />\n";
}
 
hmmm.... :confused: :( You have to help me a bit more. Where do i have to put this code. Im a extremely newbie i need everything i steps :p Thanks for helping me
 
Put the code anywhere (pretty much) inside <? ?> -tags.
Then at the place you want to print the links type in:
<?=$recentforumposts?>
 
this is what i have now and it still not work, what am i doing wrong:

<?
$recentforumget = 5; // Number of posts to get
$recentforumlength = 30; // Length of title to display before cutting off
$forumexclude = ""; // Add forum id's to exclude from get (eg private ones) sepetate by a comma

$getposts = query("SELECT tid,title,forum_id FROM ".$ibf_prefix."topics WHERE (state <> 'link')".iif($forumexclude," AND (forum_id NOT IN ($forumexclude))")." ORDER BY last_post DESC LIMIT $recentforumget");

while ($post = fetch_array($getposts)) {
$post[short_title] = iif(strlen($post[title]) > $recentforumlength,substr($pos
t[title],0,$recentforumlength)
."...",$post[title]);
$post[full_title] = $post[title];
$recentforumposts .= "<a href=\"$forumpath/index.php?act=ST&f=$post[forum_id]&t=$post[tid]\" title=\"$post[full_title]\">$post[short_title]</a><br />\n";
}
?>

<?=$recentforumposts?>
 
Have you made the connection to the database? Do you get an error?
 
hmmm i get a bunch of weird text, but no error. But nevermind i installed the Invision Portal and that does exactly what i want. Thanks for helping me.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back