How to run a MySQL database query in PHP (a Drupal how-to)

This is one of over 119 videos in a 8-hour series on called “PHP Programming Basics”. This collection is currently being released, more videos are added weekly! Click here to learn more.
In this collection, we walk you through everything you need to know to build rich PHP applications and work with PHP code in Drupal. These videos are designed to bridge the gap between Drupal site builders and programmers. We guide you gently through the basics of PHP, and work our way into building more and more complicate scripts. In our final example we build a custom CMS, which will help you understand the architecture of Drupal while flexing your new PHP skills in a practical way.

You can watch over 7 hours of FREE focused Drupal video tutorials on To view the entire list of over 739 videos (totaling over 65 hours), simply go to and scroll down.

There are currently 8 collections available, including:

* Build Your First Drupal 7 Web Site (11 hours, 212 videos)
* PHP Programming Basics (9 hours, 119 videos)
* Drupal 7 Development Core Concepts (13 hours, 140 videos)
* Change Management and Version Control (10 hours, 126 videos)
* Drupal Theming Essentials (9 hours, 80 videos)
* Drupal 6 Development and Tools (9 hours, 34 videos)
* Working with Files and the File API (3 hours, 24 videos)

Here’s a short excerpt from the video transcript: “So again, we selected our database here and then we ran a query. So we do that by using the function mysql underscore query() and then we passed it the query. So we created a number of queries like this in PHPMyAdmin, none of them were quite this simple but the language is the same. So anything that works in PHPMyAdmin in that query window will also work for the mysql_query() function. But this returns as an object, and we can’t do much with that object directly, but we can use other functions i…”


Here are a few nice things that viewers have had to say about

“Many thanks for the terrific video series on Drupal 7 – your excellent videos are simply the best source of training and information on Drupal in existence!”

“Chris has put together some of the best Drupal training material I’ve seen to date. I run a Drupal shop, and several of my developers have used Build a to get up to speed with working in Drupal 7. From what I’ve heard, they found the experience extremely valuable, and what’s great for us as a team is that they can always go back and review material when they’re tackling a particular problem.”

“Firstly, let me say that I am finding your videos extremely helpful. It’s always difficult at first to get into something new but your videos are really helping me find my way in.”

“I recently bought the download of your twelve Drupal 7 Core Concepts videos. I am new to Drupal and they are excellent. In fact they are the best tutorial videos I have ever used in the past ten years of teaching myself HTML and PHP and then Joomla (I know, I was just experimenting.) and now Drupal.”

To start learning how to build web sites, develop code or theme in Drupal, check out the full video library at