Title: shortcode Exec PHP
Last modified: August 20, 2016

---

# shortcode Exec PHP

 *  [Sam](https://wordpress.org/support/users/kulshpalace/)
 * (@kulshpalace)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/shortcode-exec-php/)
 * I have few tables in the same mysql database where word press has been installed.
   Ihave installed plug-in “Shortcode exe PHP”. Using the shortcode exec php I want
   to list the table data in a page or post. Let me know if there is any other plug-
   in that will be more useful to me.
    A help with sample code will be much appriciated.

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

 *  [M66B](https://wordpress.org/support/users/m66b/)
 * (@m66b)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/shortcode-exec-php/#post-2171406)
 * To get you started:
 *     ```
       global $wpdb;
       $posts = $wpdb->get_results("SELECT post_title FROM $wpdb->posts");
       foreach ($posts as $post)
       	echo $post->post_title . '<br />';
       ```
   
 * The [WordPress codex](http://codex.wordpress.org/Class_Reference/wpdb) contains
   a lot of useful information about database access.
 *  Thread Starter [Sam](https://wordpress.org/support/users/kulshpalace/)
 * (@kulshpalace)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/shortcode-exec-php/#post-2171580)
 * Thanks for the sample code and I got your code working on my page. But I modified
   the code as follows to look into the my real table. But the code is not showing
   any result. Could you please correct the code
 * global $wpdb;
    $products= $wpdb->get_results(“SELECT ProductName FROM $wpdb->
   products”); foreach ($products as $product) echo $product->ProductName . ‘‘;
 * Thanks
 *  [M66B](https://wordpress.org/support/users/m66b/)
 * (@m66b)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/shortcode-exec-php/#post-2171581)
 * Try replacing `$wpdb->products` by the name of the table. The `$wpdb` object 
   normally only defines WordPress tables, not custom tables.
 *  Thread Starter [Sam](https://wordpress.org/support/users/kulshpalace/)
 * (@kulshpalace)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/shortcode-exec-php/#post-2171588)
 * The table is in the same database. Do I need to give the same prefix as of wordpress
   tables?
    following is the list of the tables Table Action Records 1 Type Collation
   Size Overhead **catagory** 2 MyISAM latin1_swedish_ci 2.0 KiB – **chilly** 4 
   MyISAM latin1_swedish_ci 2.1 KiB – **class ** 32 MyISAM utf8_general_ci 3.7 KiB–**
   customer** 2 MyISAM latin1_swedish_ci 2.1 KiB – **products**
 *  299 MyISAM utf8_general_ci 33.4 KiB –
    stgorderdetails 2 MyISAM utf8_general_ci
   6.1 KiB – stgorders 1 MyISAM utf8_general_ci 8.1 KiB – subcatagory 10 MyISAM 
   utf8_general_ci 2.2 KiB – table 21 MyISAM utf8_general_ci 3.5 KiB – tmpproducts
   188 MyISAM utf8_general_ci 15.6 KiB – user 2 MyISAM latin1_swedish_ci 2.1 KiB–
   wp_ak_twitter 0 MyISAM utf8_general_ci 1.0 KiB – wp_commentmeta 17 MyISAM utf8_general_ci
   24.7 KiB 256 B wp_comments 11 MyISAM utf8_general_ci 11.2 KiB – wp_drp_coupon
   1 MyISAM latin1_swedish_ci 3.4 KiB – wp_eshop_base_products 0 MyISAM utf8_general_ci
   1.0 KiB – wp_eshop_countries 190 MyISAM utf8_general_ci 12.1 KiB – wp_eshop_discount_codes
   0 MyISAM utf8_general_ci 1.0 KiB – wp_eshop_downloads 0 MyISAM utf8_general_ci
   1.0 KiB – wp_eshop_download_orders 0 MyISAM utf8_general_ci 1.0 KiB – wp_eshop_emails
   11 MyISAM utf8_general_ci 4.2 KiB – wp_eshop_option_names 0 MyISAM utf8_general_ci
   1.0 KiB – wp_eshop_option_sets 0 MyISAM utf8_general_ci 1.0 KiB – wp_eshop_orders
   0 MyISAM utf8_general_ci 1.0 KiB – wp_eshop_order_items 0 MyISAM utf8_general_ci
   1.0 KiB – wp_eshop_rates 10 MyISAM utf8_general_ci 2.4 KiB – wp_eshop_states 
   153 MyISAM utf8_general_ci 11.3 KiB – wp_eshop_stock 0 MyISAM utf8_general_ci
   1.0 KiB – wp_links 0 MyISAM utf8_general_ci 3.6 KiB 596 B wp_ngg_album 0 MyISAM
   utf8_general_ci 1.0 KiB – wp_ngg_gallery 1 MyISAM utf8_general_ci 2.1 KiB – wp_ngg_pictures
   6 MyISAM utf8_general_ci 6.2 KiB – wp_options 323 MyISAM utf8_general_ci 392.9
   KiB 204 B wp_postmeta 287 MyISAM utf8_general_ci 65.1 KiB 440 B wp_posts 220 
   MyISAM utf8_general_ci 805.8 KiB 479.8 KiB wp_terms 14 MyISAM utf8_general_ci
   8.5 KiB – wp_term_relationships 17 MyISAM utf8_general_ci 3.4 KiB 21 B wp_term_taxonomy
   15 MyISAM utf8_general_ci 4.6 KiB – wp_usermeta 85 MyISAM utf8_general_ci 16.9
   KiB – wp_users 4 MyISAM utf8_general_ci 4.5 KiB 32 B wp_vslider 4 MyISAM latin1_swedish_ci
   4.1 KiB – wp_woo_ratings 0 MyISAM utf8_general_ci 1.0 KiB – 42 table(s) Sum 1,932
   MyISAM latin1_swedish_ci 1.4 MiB 481.3 KiB
 *  [M66B](https://wordpress.org/support/users/m66b/)
 * (@m66b)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/shortcode-exec-php/#post-2171590)
 * Apparently not: `products`.

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

The topic ‘shortcode Exec PHP’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/shortcode.svg)
 * [Shortcode](https://wordpress.org/plugins/shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcode/reviews/)

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 5 replies
 * 2 participants
 * Last reply from: [M66B](https://wordpress.org/support/users/m66b/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/shortcode-exec-php/#post-2171590)
 * Status: not resolved