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 maddren12,793 Points
Filtering MySQL and PHP results
Hey guys, I've been watching Randy's tutorials about creating a PHP application. I know how to display the data in as list items on my store front, I just can't seem to figure out how to filter the results that are displayed to the client.
My table contains vehicle data such as the manufacturer and model in columns, I want to use a select element to let users filter what manufacturer they want to show as the listing results.
How can I display only the manufacturers that are in stock within the select element. The SQL table changes often so if it want to display all of the manufacturers possible because it would clutter the select element.
When the user selects the first element I need it to then show the models of the manufacturer.
How could I do this?
Chris Malcolm2,909 Points
just a suggestion without seeing those tutorials, i'm assuming you also have an in_stock column (or something like that) too? you can include this in your SQL query
SELECT * FROM
or something like that. then your results will only have those that meet your criteria.