phpBB mod help

Discussion in 'PHP' started by amplifiedshock, Mar 6, 2008.

  1. #1
    I have searched for this EVERYWHERE and I can't find this for phpBB 3.0.0.

    Displaying a list recent phpBB threads on an external page.

    I can only find it for phpBB 2... Any help would be much appreciated.
     
    amplifiedshock, Mar 6, 2008 IP
  2. swishman

    swishman Well-Known Member

    Messages:
    1,264
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #2
    are you welling to pay for this?
     
    swishman, Mar 6, 2008 IP
  3. amplifiedshock

    amplifiedshock Active Member

    Messages:
    147
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Depends on the cost. I was hoping it existed already...
     
    amplifiedshock, Mar 6, 2008 IP
  4. sharqi

    sharqi Guest

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    its super easy ........

    its a db query and basic pagination.. do not pay for it.

    You will need to input your username, password, db name etc.

    Also change the name of tables and fields to match your phpbb3 databse..

    
    <?php
    //our function getPosts($number);
    
    function getPosts() {
    
    $username = "dbusername";
    $password = "dbpassword";
    $hostname = "localhost"; //or your host IP
    //connect to the phpbb database engine......
    $dbh = mysql_connect($hostname, $username, $password) 
    	or die("Unable to connect to MySQL");
    
    //select our phpbb databse
    $selected = mysql_select_db("phpbb1",$dbh) 
    	or die("Could not select DB");
    
    //make a query to get last $number topics from the forum....
    //the not in is where you can add the private or hidden forum ID's - just look in the forums table and you will see the forum names and the ID's.
    $myQuery =  'SELECT topic_id, topic_title FROM phpbb_topics WHERE forum_id NOT IN (\'16\', \'17\', \'18\') ORDER BY topic_id DESC LIMIT $number';
    //run the query or fail with the error
    $myQueryExecute = mysql_query($myQuery) or die (mysql_errror());
    //this is the pagination or ourput
    
    //while there are rows available from the result...
    while ($container = mysql_fetch_row($myQueryExecute)) {
    //echo to the browser ......
    echo '<a href="' . 'http://myCoolSite.com/forum/viewtopic.php?t=' . 
    //the image is a little image that looks pretty at the side of each recent post....
    //there is a <hr> horizontal rule between the posts to make it look pretty when combines with css....
    $container[0] . '"' . ">" . '<img src="images/comment.gif" />' . "  " . $container[1] . "</a>" . "<br><hr>"; 
    //close the loop
    }
    //close the database connection
    mysql_close($dbh);
    //unset our variable $number
    unset($number);
    //close the function
    }
    ?>
    
    PHP:
    Now to use this function in a page
    
    <?php
    
    require("ourFunctions.php");
    //gets the last 5 posts and prints them to the screen with the formatting set in the function as above...
    echo "The last posts were...........<br /><br />";
    getPosts(5);
    
    ?>
    
    PHP:
    Hope that helps a bit.
     
    sharqi, Mar 7, 2008 IP
    amplifiedshock likes this.
  5. amplifiedshock

    amplifiedshock Active Member

    Messages:
    147
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Thank-you very much! +rep
     
    amplifiedshock, Mar 7, 2008 IP
  6. lace-rules

    lace-rules Guest

    Messages:
    115
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks very much. I would of just written the code which would of taken me a while, but sharqi has already done it which saves me a lot of time.

    Thanks!
     
    lace-rules, Sep 29, 2008 IP