Title: How do I use $wpdb?
Last modified: August 20, 2016

---

# How do I use $wpdb?

 *  [shabbaranks](https://wordpress.org/support/users/shabbaranks/)
 * (@shabbaranks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-use-wpdb/)
 * Hi,
 * Totally new to all this and am trying to understand it all. Ive just read that
   you can query the database with wpdb. The guide states you need to globalize 
   it first – could anyone give me an example of how I do this please?
 * Thanks

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

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-use-wpdb/#post-2347436)
 * [http://codex.wordpress.org/Class_Reference/wpdb](http://codex.wordpress.org/Class_Reference/wpdb)
 * to globalize use `global $wpdb;` before your query.
 *  Thread Starter [shabbaranks](https://wordpress.org/support/users/shabbaranks/)
 * (@shabbaranks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-use-wpdb/#post-2347445)
 * Thanks keesiemeijer so in theory this should work
 *     ```
       <?php
       global $wpdb;
       ($mylink) = $wpdb->get_results("SELECT Status FROM Activity");
       echo ($mylink)
       ?>
       ```
   
 * or do I need something else? Thank you

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

The topic ‘How do I use $wpdb?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [shabbaranks](https://wordpress.org/support/users/shabbaranks/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-use-wpdb/#post-2347445)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
