Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

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.

Thanks

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'.