Title: Custom queries
Last modified: August 19, 2016

---

# Custom queries

 *  Resolved [sjwright](https://wordpress.org/support/users/sjwright/)
 * (@sjwright)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-queries-4/)
 * Hi
 * I am relatively new to wordpress, and for a job I’m doing for a client a custom
   plugin is required.
 * I’m doing a test query but I don’t know if I’m doing it right, I just cant get
   my head round the $wpdb and the codex solutions aren’t helping either.
 * Basically all I want to do at this stage is pull results out of a custom table,
   to no avail. Here’s the code I tried…
 *     ```
       // Get the ranges from the database
       	$range_rows = $wpdb->get_results("SELECT * FROM wp_hb_ranges ORDER BY id DESC");
   
       	foreach ($range_rows as $range_row) {
       		echo $range_row->name;
       	}
       ```
   
 * What am I doing wrong?

Viewing 1 replies (of 1 total)

 *  Thread Starter [sjwright](https://wordpress.org/support/users/sjwright/)
 * (@sjwright)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-queries-4/#post-1531254)
 * School boy error, was running the script locally, but the tables were on our 
   development server, ignore post!

Viewing 1 replies (of 1 total)

The topic ‘Custom queries’ is closed to new replies.

## Tags

 * [custom queries](https://wordpress.org/support/topic-tag/custom-queries/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 1 reply
 * 1 participant
 * Last reply from: [sjwright](https://wordpress.org/support/users/sjwright/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/custom-queries-4/#post-1531254)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
