Title: Building a Table Dynamically
Last modified: August 31, 2016

---

# Building a Table Dynamically

 *  Resolved [toonbon](https://wordpress.org/support/users/toonbon/)
 * (@toonbon)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/building-a-table-dynamically/)
 * I’ve built a TablePress table that you can see by selecting REGISTRY ENTRIES 
   at the top of steve3.wpengine.com. The data shown here is all static. Now I need
   to build the table dynamically as the page is rendered, using data in the database.
   So I don’t know initially what the cells will contain and I don’t know how many
   rows the table will have until I pull the records from the database.
 * Can I do this with TablePress?
 * Thanks
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/building-a-table-dynamically/#post-6930264)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * Unfortunately, I have bad news here. Something like this is not possible with
   TablePress, as it’s not a database replacement system. It can only read its own
   static tables.
 * For access to the database, I can therefore only suggest a custom PHP/mySQL solution.
 * Regards,
    Tobias
 *  Thread Starter [toonbon](https://wordpress.org/support/users/toonbon/)
 * (@toonbon)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/building-a-table-dynamically/#post-6930333)
 * Assuming I can get the data from the database is there some way I can poke it
   into the cells as PHP is building the page, maybe some function like set($data,
   $row, $col); ?
 * Thanks
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/building-a-table-dynamically/#post-6930380)
 * Hi,
 * you could use the functions like `save()` in the model-table.php file, but I 
   still don’t think that this would be a good solution. If you already have the
   data in the database, it doesn’t make sense to duplicate that.
 * One idea could be to overwrite the data that would be rendered with that that
   you get from the database, e.g. by using a filter hook like `tablepress_table_render_data`
   in the class-render.php file.
 * Regards,
    Tobias
 *  Thread Starter [toonbon](https://wordpress.org/support/users/toonbon/)
 * (@toonbon)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/building-a-table-dynamically/#post-6930420)
 * Hi Tobias,
 * I like the idea of the filter hook at tablepress_table_render_data, but I suspect
   I’m still blocked because the table that you build will have the static number
   of rows. But I don’t know the actual number of rows in the table until I see 
   how many records come back from the query. Before I give up I wanted to check
   one last time with you to see if you see anyway to add one or more rows to the
   table as it’s being built.
 * Thanks,
    Steve
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/building-a-table-dynamically/#post-6930427)
 * Hi,
 * the number of rows does not matter here. That filter basically passes the current
   state of the (dummy) table to your PHP function, which simply has to return the
   new/desired version of the table (in the correct array format). The size does
   not matter. TablePress will then render/print what your function returned.
 * Regards,
    Tobias

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

The topic ‘Building a Table Dynamically’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/building-a-table-dynamically/#post-6930427)
 * Status: resolved