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!

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


nicholas maddren
nicholas maddren
12,793 Points

PHP select elements

Hey guys I'm just wondering how I can display MySQL data in a select element with PHP?

I have vehicle data stored in a table that has basic vehicle information such as 'Manufacturers' and other data.

How would I list the manufactured cars that are AVAILABLE in the select element for example if there sin't a Ferrari in the SQL table I don't want it to display as an option in the select element.

How can I do this? Randy didn't show an example of this in his project.


1 Answer

Łukasz Czuliński
Łukasz Czuliński
8,646 Points

How is the DB set up? Do you have a column that lists if the car is available or not? Because it sounds like all you need is a SELECT statement using the WHERE clause. So like SELECT * FROM cars WHERE availability = 'available'.