Title: Database query instead of example array
Last modified: August 21, 2016

---

# Database query instead of example array

 *  [Erixz](https://wordpress.org/support/users/erixz/)
 * (@erixz)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/database-query-instead-of-example-array/)
 * Hi!
 * I have read posts here and Googled around to try to understand how to use custom
   querys instead of example_data but I do not understand how to do.
 * It would be very nice if someone could just show an example with querys or just
   make a suggestion.
 * Thanks in advance!
 * [http://wordpress.org/plugins/custom-list-table-example/](http://wordpress.org/plugins/custom-list-table-example/)

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

 *  Plugin Author [Dutch van Andel](https://wordpress.org/support/users/veraxus/)
 * (@veraxus)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/database-query-instead-of-example-array/#post-4348675)
 * Hey Erixz,
 * You use the `$wpdb` global object to interact with the WordPress database.
 * You can find a very detailed breakdown (with examples!) on the WordPress Codex
   here:
 * [http://codex.wordpress.org/Class_Reference/wpdb](http://codex.wordpress.org/Class_Reference/wpdb)
 * If you are new to plugin development with WordPress, I would encourage you to
   read the excellent (and free) [WordPress Plugin Developer’s Handbook](http://make.wordpress.org/docs/plugin-developer-handbook/),
   which covers a lot of basics like working with database queries in WordPress.
 *  [alfiya](https://wordpress.org/support/users/alfiya/)
 * (@alfiya)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-query-instead-of-example-array/#post-4348681)
 * Hi Erixz,
    I had the same problem. I solved it by inserting a piece of code after“**
   $this->process_bulk_action();**“ The code: $query = “SELECT * FROM {$wpdb->posts}”;
   $totalitems = $wpdb->query($query); $this->items = $wpdb->get_results($query);
 * After that you should create a function “display_rows()”
    Please refer to this
   website [http://wp.smashingmagazine.com/2011/11/03/native-admin-tables-wordpress/](http://wp.smashingmagazine.com/2011/11/03/native-admin-tables-wordpress/)
   for the details about the “**display_rows()**” function. Make sure you read the
   comments because there are some mistakes in the code and users fixed them.
 *  [David Macfarlane](https://wordpress.org/support/users/davidmacf/)
 * (@davidmacf)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-query-instead-of-example-array/#post-4348682)
 * Line number 383
 * Change
    $data = $this->example_data;
 * to
    $sql = “SELECT ID,title,rating,director FROM wp_films”; $data = $wpdb->get_results(
   $sql,ARRAY_A);
 * Obviously you’ll need to create the database table
 * I hope this helps someone

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

The topic ‘Database query instead of example array’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-list-table-example.svg)
 * [Custom List Table Example](https://wordpress.org/plugins/custom-list-table-example/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-list-table-example/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-list-table-example/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-list-table-example/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-list-table-example/reviews/)

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * 3 replies
 * 4 participants
 * Last reply from: [David Macfarlane](https://wordpress.org/support/users/davidmacf/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/database-query-instead-of-example-array/#post-4348682)
 * Status: not a support question