Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Integrating PHP with Databases Querying the Database with PHP Querying the Database

Alex Forseth
Alex Forseth
8,017 Points

What does the information stored look like? How was it created?

So I get that we have information on a database that references the media library. But what format is it in. For instance:

try {
  $results = $db->query("SELECT title, category FROM Media"); 

What type of format is the SELECT title in? what about category?

This might be kind of a lofty and broad question but anything that will make me understand better.

Ahsan Parwez
Ahsan Parwez
3,139 Points

Here Media is the table name stored in the database and the query "SELECT title, category FROM Media" will select two column values which is 'title' and 'category'.

If you are confused about try {} then this is used for exception handling purposes. try{} block contains the executable code if an error occurred then it will handle by catch{} block. I think this is an advance topic for you yet.

1 Answer

You actually just performed a simple query in SQL, but you used PHP to do it. At this point in the course we aren't introduced yet as to how to view or render the results. Bur rest assured that if you get the "Retrieved Results" string, then you have performed a query to the database successfully.