Title: retrieving data from wpdatatable
Last modified: July 28, 2023

---

# retrieving data from wpdatatable

 *  Resolved [antl19](https://wordpress.org/support/users/antl19/)
 * (@antl19)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/retrieving-data-from-wpdatatable/)
 * I’m trying to retrieve data from a simple WP data table I created. The table 
   definitely exists and the short code is [wpdatatable id=1] but when trying the
   code below i continue to see “no data is found”
 * I think I’m using the wrong table name in the code below but not sure. Any help
   would be much appreciated.
 *     ```wp-block-code
       <?php
       /*
       Plugin Name: Table Test Plugin
       Description: A simple plugin to test fetching data from a wpDataTables table.
       */
   
       // Shortcode for displaying table data
       function table_test_display_shortcode() {
           ob_start();
   
           // I thought '1' is  the right  ID but not sure
           $table_id = 1;
   
           // Load wpDataTables plugin class
           if (class_exists('WPDataTable')) {
               // Get the wpDataTables object
               $wpdt = new WPDataTable($table_id);
   
               // Get the table data
               $table_data = $wpdt->get_data();
   
               if ($table_data) {
                   echo '<table>';
                   echo '<tr>';
                   foreach ($table_data[0] as $column_name => $value) {
                       echo '<th>' . $column_name . '</th>';
                   }
                   echo '</tr>';
   
                   foreach ($table_data as $row) {
                       echo '<tr>';
                       foreach ($row as $value) {
                           echo '<td>' . $value . '</td>';
                       }
                       echo '</tr>';
                   }
                   echo '</table>';
               } else {
                   echo 'No data found.';
               }
           } else {
               echo 'wpDataTables plugin is not activated.';
           }
   
           return ob_get_clean();
       }
       add_shortcode('table_test_display', 'table_test_display_shortcode');
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * (@wpdatatables)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/retrieving-data-from-wpdatatable/#post-16935780)
 * Hello,
   are you using the Lite version of our Plugin or Premium?And if you can
   confirm what is this table type that you are trying to pull the data for in this
   use case?If this is a [Simple Table](https://wpdatatables.com/documentation/creating-new-wpdatatables-with-table-constructor/creating-a-simple-table-with-wpdatatables/)
   type,or any table type from the wpDataTables Lite version, such as a table linked
   to CSV, Excel, etc;
 * These “non-server-side” datatables are not saved in your database like our [Manual tables](https://wpdatatables.com/documentation/creating-new-wpdatatables-with-table-constructor/building-and-filling-in-the-tables-manually/)(
   they are not available in the Lite version),
    but instead, their data is stored
   in a database table named wp_wpdatatables_rows. So, pulling data from the database
   through any kind of SQL Query on your website ( through your Database Management
   Tool or PHP code) is a bit more complex because this database table stores data
   in JSON format, not like manual tables (columns * rows).In other words, we do
   not have any built-in way to achieve this with tables made by the Lite Plugin
   version.Of course, if you have coding knowledge or your own developer,you can
   try to go for a custom solution,but that is not covered by our Support.In case
   If you have premium wpDataTables, or if you are interested in any workarounds
   that might be possible with the premium version,please open a ticket on our [main Support platform here](https://tmsplugins.ticksy.com/),
 *  and one of our Agents will respond as quickly as possible to advise if they 
   have any workarounds.
 * Premium products are not supported in these forums, as per [this comment](https://wordpress.org/support/topic/error-when-not-logged-into-wordpress-backend/#post-15050671)
   by WordPress.org moderators.
 * Thank you for understanding. 
 * Kind regards.
    -  This reply was modified 2 years, 10 months ago by [wpDataTables](https://wordpress.org/support/users/wpdatatables/).

Viewing 1 replies (of 1 total)

The topic ‘retrieving data from wpdatatable’ is closed to new replies.

 * ![](https://ps.w.org/wpdatatables/assets/icon-128x128.gif?rev=3010404)
 * [wpDataTables - WordPress Data Table, Dynamic Tables & Table Charts Plugin](https://wordpress.org/plugins/wpdatatables/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpdatatables/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpdatatables/)
 * [Active Topics](https://wordpress.org/support/plugin/wpdatatables/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpdatatables/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpdatatables/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/retrieving-data-from-wpdatatable/#post-16935780)
 * Status: resolved