Title: Running PHP SQL inside a WP page
Last modified: August 30, 2016

---

# Running PHP SQL inside a WP page

 *  [d_dangio](https://wordpress.org/support/users/d_dangio/)
 * (@d_dangio)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/running-php-sql-inside-a-wp-page/)
 * Is This Possible? If So How?
    Run a PHP SQL query to display a list of names 
   that resides in a MySQL database table. Can I run this from inside a Page created
   inside WP? $sql = “SELECT * FROM `TABLE 1` LIMIT 0, 30 “; $sql = “SELECT track_name,
   media_name, genre “. “FROM TABLE 1 “. Thanks!

Viewing 1 replies (of 1 total)

 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/running-php-sql-inside-a-wp-page/#post-6646181)
 * Hi,
 * No… it’s not recommended (and would result in erratic behavior.. and probably
   won’t work anyway) adding PHP inside a post or page.
 * I would suggest using a [child theme](https://codex.wordpress.org/Child_Themes)..
   and then [creating a shortcode](https://codex.wordpress.org/Shortcode_API) in
   your child theme functions.php file.
 * Then, use the shortcode in your post or page to display the custom content.

Viewing 1 replies (of 1 total)

The topic ‘Running PHP SQL inside a WP page’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Josh](https://wordpress.org/support/users/josh401/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/running-php-sql-inside-a-wp-page/#post-6646181)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
