Help creating a search box

Discussion in 'PHP and MySQL' started by Jholden, Jan 18, 2010.

  1. Jholden New Member

    I am looking to create a box that will allow users to search by Make, then it will load model and them allow them to search.

    Ie: A user could select BMW--- And it will load under model E36,E46,E92 and so on. But i want to be able to have every car manufacture
  2. chanelssc New Member

    Hi,

    This is quite a common task.
    In your database:
    Create a table to store the car makes e.g BMW, Mercedes, Audi and create another to store the models 316,516, ECLASS, A4, A5 etc and with each model having a link back to the table storing the make of each car

    MAKE
    1 | BMW
    2 | Mercedes
    3 | Audi

    MODEL
    1 | 316 | 1
    2 | 516 | 1
    3 | ECLASS | 2
    4 | A4 | 3
    5 | A5 | 3

    Now you can use a combination of php and javascript.
    Populate the first dropdown box with the car models. Use the onChange event to trigger the population of the second combobox with the models. You'll be able to get the id of what make is selected in the first and retrieve all models for that make.

    There are full examples online with country \ city as the example but same applies.

    Code Examples -> Dynamic Dropdown for Country and City List

    Try searching for "php dynamic combobox"

    HTH