Title: Show data in post from some remote database &#8211; solution? plugin?
Last modified: August 21, 2016

---

# Show data in post from some remote database – solution? plugin?

 *  [aargambit](https://wordpress.org/support/users/aargambit/)
 * (@aargambit)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/show-data-in-post-from-some-remote-database-solution-plugin/)
 * Hi
    I received acccess to some database where some personal data is stored. I
   need to get them and show them in one of the posts. I do know how to do such 
   things on handmade sites but dont know how and where make a query in wordpress
   environment. Ive heard about some widgets which allow to use PHP directly on 
   the site or posts. Is it good way to aproach it or should i try to make some 
   appropriate functions in some specific php files or make my own files?
 * In addition i must say that i cant make any hevy wordpress/plugins changes which
   could block me from updates. As for the themes im using child theme as well.
 * Thanks in advance for any help.

Viewing 1 replies (of 1 total)

 *  Thread Starter [aargambit](https://wordpress.org/support/users/aargambit/)
 * (@aargambit)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/show-data-in-post-from-some-remote-database-solution-plugin/#post-5106880)
 * Ok i found some track (it was hard to make proper sentece for uncle google) here…
 * [http://wordpress.stackexchange.com/questions/1604/using-wpdb-to-connect-to-a-separate-database](http://wordpress.stackexchange.com/questions/1604/using-wpdb-to-connect-to-a-separate-database)
 * I’ll quote correct answer in case link will die.
 * > Yes it’s possible.
   > The wpdb object can be used to access any database and query any table. Absolutely
   > no need to be WordPress related, which is very interesting.
   > The benefit is the ability to use all the wpdb classes and functions like get_results,
   > etc so that there’s no need to re-invent the wheel.
   > Here’s how:
   >     ```
   >     $mydb = new wpdb('username','password','database','localhost');
   >     $rows = $mydb->get_results("select Name from my_table");
   >     echo "<ul>";
   >     foreach ($rows as $obj) :
   >        echo "<li>".$obj->Name."</li>";
   >     endforeach;
   >     echo "</ul>";
   >     ```
   > 
 * This is how to connect with second database. I will change it a little bit to
   my needs and put it to functions.php in child theme. In second step ill probably
   use Shortcode API
 * [http://codex.wordpress.org/Shortcode_API](http://codex.wordpress.org/Shortcode_API)
 * This way ill create a shortcode which ill use in specific post.
 * If my idea is wrong then please correct me here, i wont mark this topic as resolved
   untill i fully get my task done.

Viewing 1 replies (of 1 total)

The topic ‘Show data in post from some remote database – solution? plugin?’ is closed
to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [queries](https://wordpress.org/support/topic-tag/queries/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [remote database](https://wordpress.org/support/topic-tag/remote-database/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [aargambit](https://wordpress.org/support/users/aargambit/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/show-data-in-post-from-some-remote-database-solution-plugin/#post-5106880)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
