Title: Adding content from other database table
Last modified: August 18, 2016

---

# Adding content from other database table

 *  [cheriejd](https://wordpress.org/support/users/cheriejd/)
 * (@cheriejd)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/)
 * I need to add some pulldowns and dates from a tour database that is separate 
   from the wordpress database.
 * How do I go about linking to that database and adding the content. Do I add the
   include in the header.php?
 * Cannot find info in the docs or in this forum.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633318)
 * database connections within wordpress are handled the same way they are handled
   in any other situation. EXCEPT, that you need to realize that WP doesnt close
   it’s own connections so you may run into trouble with that …
 * adding content?
 * edit the theme file responsible for where you want it displayed.
 * Includes? header.php?
 * sure. why not.
 *  Thread Starter [cheriejd](https://wordpress.org/support/users/cheriejd/)
 * (@cheriejd)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633326)
 * ok, WHERE are they handled? The only place I am seeing a database connection 
   is in the config.php file.
 * Usually I place my database info in a file and then connect to it through a php
   call on a page above the head info.
 * I don’t need this on all pages, so putting it in the header.php seems like overkill.
 * Once I have made the connection, dropping everything into the specific page should
   be simple (at least according to all I have read).
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633329)
 * youre going the wrong direction. If you are trying to make a database connection
   in your sidebar, for instance, a generic example:
 *     ```
       <?php
       $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
       if (!$link) {
           die('Could not connect: ' . mysql_error());
       }
       echo 'Connected successfully';
       mysql_close($link);
       ?>
       ```
   
 * would go in the theme file responsible for what is seen in the sidebar.
 * as to what you described.. you do THAT the same way, just call in the include
   from inside the theme file (3rd time saying that).
 *  [Darfuria](https://wordpress.org/support/users/darfuria/)
 * (@darfuria)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633474)
 * I’m trying to select the 10 latest posts from a phpBB3 forum and display them
   in my sidebar.
 * This is the code I’m using:
 *     ```
       <ul>
       <?php
       $bb_server = 'localhost';
       $bb_dbname = 'economicals_forum';
       $bb_dbuser = 'root';
       $bb_dbpass = '';
   
       $bb_connect = mysql_connect($bb_server, $bb_dbuser, $bb_dbpass) or die ('Cannot connect to the database because: ' . mysql_error());
       mysql_select_db("$bb_dbname");
   
       $sql = ("SELECT * FROM phpbb_topics ORDER BY topic_last_post_time DESC LIMIT 0,10");
       $result = mysql_query($sql);
       for($x=1;$x<=10;$x++)
       {
       $row = mysql_fetch_array($result);
       echo ("<li><a href = \"/forum/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\">$row[topic_title]</a></li>");
       }
       mysql_close($bb_connect);
       ?>
       </ul>
       ```
   
 * And this is the error I’m getting:
 * Warning: mysql_error(): 8 is not a valid MySQL-Link resource in C:\xampp\htdocs\
   economicals\www.economicals.org\wp-includes\wp-db.php on line 236
 *  [dem](https://wordpress.org/support/users/dem/)
 * (@dem)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633475)
 * I was looking for same thing. Here is what i was trying to do.
 * I want to every editor have his own wordpress blog. E.G. mydomain.com/John , 
   mydomain.com/Matt, mydomain.com/Lennon.
 * I’m Going to develop a website where there’s going to be 3 editors. But first
   of all i want to display in the front page the latest posts of John, latests 
   posts from Matt, and latests posts from Lennon.
 *  [dem](https://wordpress.org/support/users/dem/)
 * (@dem)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633476)
 * I was thinking… in fact, an easy example is wordpress.com
 * There are users, every user have his own subdomain… and in front page there are
   the latests posts…etc.
 *  [mikesmobile](https://wordpress.org/support/users/mikesmobile/)
 * (@mikesmobile)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633527)
 * I had a similar question/issue. I needed to add a table and then access the data
   in that table –> having it displayed on the WordPress blog.
 * I found this post yesterday, [http://wordpress.org/support/topic/196353](http://wordpress.org/support/topic/196353),
   but noticed it did not have a recent response or solution. I submitted another
   post to the topic and low and behold, I got a response (thanks [MichaelH](http://codex.wordpress.org/User:MichaelH)).
   The plugin that MichaelH refers to looks promising. I have not installed and/
   or tested it yet, but I did read up a little on how to use the [wpdb codex](http://codex.wordpress.org/wpdb).
   I tested it a little and that worked.
 * See also:
    [http://wordpress.org/support/topic/196830](http://wordpress.org/support/topic/196830)
   [http://wordpress.org/support/topic/196353](http://wordpress.org/support/topic/196353)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Adding content from other database table’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 5 participants
 * Last reply from: [mikesmobile](https://wordpress.org/support/users/mikesmobile/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/adding-content-from-other-database-table/#post-633527)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
