1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Posts on external webpage

Discussion in 'XenForo Development Discussions' started by Mufasa, Aug 1, 2013.

  1. Mufasa

    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?
     
  2. EasyTarget

    EasyTarget Well-Known Member

  3. Mufasa

    Mufasa Active Member

    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.
     
  4. EasyTarget

    EasyTarget Well-Known Member

    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. :)
     
  5. Mufasa

    Mufasa Active Member

    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.
     

Share This Page