Title: Dinamiccally pull value from database
Last modified: August 30, 2016

---

# Dinamiccally pull value from database

 *  [elsnare](https://wordpress.org/support/users/elsnare/)
 * (@elsnare)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/dinamiccally-pull-value-from-database/)
 * Hello guys!
    I’m looking for a way to update editor content with value pulled
   from DB based on a select menu value.
 * The base code works something like this:
 *     ```
       <select name="user_input">
       <option value="ID1"></option>
       <option value="ID2"></option>
       <option value="ID3"></option>
       </select>
   
       global $wpdb;
       $content = $wpdb->get_var( "SELECT content FROM $wpdb->table WHERE post_id=$user_input" );
   
       $editor_id = 'mycustomeditor';
       wp_editor( $content, $editor_id );
       ```
   
 * I need this to happen without a page reload.
    I will greatly appreciate any help
   or tips.

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

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/dinamiccally-pull-value-from-database/#post-6726519)
 * You should be able to find a plugin that does this kind of thing, you will be
   able to adapt it to your needs.
 * The page that the browser loads will be a custom page template of your child 
   theme, this page will load the required javascript and also your option code.
   
   In the browser you will have javascript hooking the select/option control, upon
   each change it will instigate an AJAX call to your web server that specifies 
   the requested page ID, the server side PHP file invoked by the AJAX request will
   do the SQL query to fetch the page contents, and send this back to the browser
   in the AJAX response. At the browser the javascript receiving this response will
   inject the response into the DOM.
 * Here is an AJAX referance:
    [https://developer.wordpress.org/plugins/javascript/ajax/](https://developer.wordpress.org/plugins/javascript/ajax/)
 * Suggest that you search and browser plugins to find something that you can adapt.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/dinamiccally-pull-value-from-database/#post-6726533)
 * I just want to make it clear that if you adapt a plugin in this manner, you would
   essentially fork it under a new name, except it’s not published. Don’t hack up
   a plugin then try to update it! You’ll lose all of your custom code.
 * Ross’ summary is so succinct and accurate I would suggest you piece together 
   your own code based on it and take examples from other plugins and code snippets
   as needed rather than trying to find the closest plugin to your needs. I think
   it’s easier to find elements that do what you want than entire plugins.
 * IMHO of course, do what works best for you.

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

The topic ‘Dinamiccally pull value from database’ is closed to new replies.

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [editor](https://wordpress.org/support/topic-tag/editor/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/dinamiccally-pull-value-from-database/#post-6726533)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
