Posts on external webpage

Mufasa

Active member
Not sure where to post it, this seemed the most appropriate place.

Im look to pull data from the xf database - new threads made in a certain forum and show them on an external page, on the same domain and web server. e.g >

New post made in News & Announcements > INSERT data into database (forum_, table: xf_threads)
External webpage > connects to database > looks in forum_ > xf_threads > field: node_id=4 for new threads (first post only) > pulls data > places on external webpage.

Pretty sure thats how it should go database wise anyway. I cant seem to figure out the code lol. i got this far:

Code:
<?php

try {
    $pdo = new PDO('mysql:host=localhost;dbname=forum_', 'username', 'password');
} catch (PDOException $e) {
    exit('Database Error.');
}
class Article {
        public function fetch_all() {
                global $pdo;

                $query = $pdo->prepare("SELECT * FROM xf_threads");
                $query->execute();

                return $query->fetchAll();
        }
        public function fetch_data($node_id) {
            global $pdo;
            $query = $pdo->prepare("SELECT * FROM xf_threads WHERE node_id = 4");
            $query->execute();

            return $query->fetch();

        }
}

?>

Now, in theory that should work, well.. it does on a cms script ive just coded and it works fine. All i did here was just edit the values to match the xf database..

Any ideas?
 
Oh well i have to say, that does look promising. I have to ask tho, can i implement one of those codes onto a design i already have rather then just editing the default design? If so, then ill download it lol.
You can use the code any way you see fit. Mash it up the way that you need. Post a screen shot after you get it working. :-)
 
Thanks. You have separated everything in so many places lol, might take me a little bit to gather the required code lol. Ill let you know how i get on.
 
Top Bottom