latest posts

Discussion in 'Site Problems & Feedback' started by sboulema, Dec 29, 2002.

  1. sboulema

    sboulema Moderator

    Messages:
    2,846
    Location:
    Amstelveen, The Netherlands
    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.
     
  2. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    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";
    }
    
     
  3. sboulema

    sboulema Moderator

    Messages:
    2,846
    Location:
    Amstelveen, The Netherlands
    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
     
  4. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    Put the code anywhere (pretty much) inside <? ?> -tags.
    Then at the place you want to print the links type in:
    <?=$recentforumposts?>
     
  5. sboulema

    sboulema Moderator

    Messages:
    2,846
    Location:
    Amstelveen, The Netherlands
    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?>
     
  6. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    Have you made the connection to the database? Do you get an error?
     
  7. sboulema

    sboulema Moderator

    Messages:
    2,846
    Location:
    Amstelveen, The Netherlands
    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.