I am new to php and my sql so please bear with me. I am using a program php runner.
I have 3 fields year make model that need to be drop down lists dependent on the prior selection. for instance if they chose 200 toyota there wont be a tercel as a choice be cause it wasn't made. i have a csv file that has all the correct data. what i need to know is what tables and what fields to create. and how to set up the link field so make only shows makes for the year chosen and model shows only those for the chosen year and make
thanks!

Hey there!

The method I used on my website (maintainedauto.com) is this:

You have 2 SQL tables, 1 for the makes (honda, toyota) and 1 for the models (Accord, Camry)

Your makes table would be like this:
Table: makes
make_id MEDIUMINT(8) UNSIGNED PRIMARY KEY AUTO INCREMENT
make_name VARCHAR(255)

Your models table would be similar but include 1 more column:
Table: models
model_id MEDIUMINT(8) UNSIGNED PRIMARY KEY AUTO INCREMENT
model_name VARCHAR(255)
make_id MEDIUMINT(8) UNSIGNED

The way that this works is that all of your makes would be in the makes table and the models OF the maker would be in models.

So if Toyota has an ID of 1 (in the makes table) you can query your models table like so:

SELECT * FROM models WHERE make_id = 1

Are you familiar with any javascript frameworks? Because we can do this with an AJAX call and populate the select for models based on the make selected.

ALSO! Are you supposed to be including the year and a definition?

thanks for the reply im grateful i don't know how to use java script yet:(
I do need a year for instance there is no 2010 Toyota tercel
i am learning a program called php runner i need to know what tables to make and what fields to create (which you told me i think except for the year
i have a csv file of all the years makes and models and i know how to import them into php admin i just don't know what to put where here is a clip from that file
Year Make Model
1990 Acura Integra GS
1990 Acura Integra LS
1990 Acura Integra RS
1990 Acura Legend
1990 Acura Legend L
1990 Acura Legend LS
1990 Alfa Romeo Spider Graduate
1990 Alfa Romeo Spider Quadrifoglio
1990 Alfa Romeo Spider Veloce
also in php runner i dont know how to set up the link and display fields or the category control or field
so i can create the tables you instruct me to then what?:?:

i so appreciate your help!!!!!!!!!!!!!!!!!!:)

Honestly I have no idea what PHP Runner is because I've always programmed my websites from scratch.

If we were talking code then I'd be able to help you a lot more...

Sorry :(

if you give me the code i can get someone to help me out from there
thanks

I think I understand but how would I do the year?

I UNDERSTAND IT NOW. how would I do the year ?

Hey there!

The method I used on my website (maintainedauto.com) is this:

You have 2 SQL tables, 1 for the makes (honda, toyota) and 1 for the models (Accord, Camry)

Your makes table would be like this:
Table: makes
make_id MEDIUMINT(8) UNSIGNED PRIMARY KEY AUTO INCREMENT
make_name VARCHAR(255)

Your models table would be similar but include 1 more column:
Table: models
model_id MEDIUMINT(8) UNSIGNED PRIMARY KEY AUTO INCREMENT
model_name VARCHAR(255)
make_id MEDIUMINT(8) UNSIGNED

The way that this works is that all of your makes would be in the makes table and the models OF the maker would be in models.

So if Toyota has an ID of 1 (in the makes table) you can query your models table like so:

SELECT * FROM models WHERE make_id = 1

Are you familiar with any javascript frameworks? Because we can do this with an AJAX call and populate the select for models based on the make selected.

ALSO! Are you supposed to be including the year and a definition?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.