HELP - php mysql db search from form input

Status
Not open for further replies.

ibexpiotr

In Runtime
Messages
243
Location
New York
so heres the deal. ive got a db table car_inventory. in there i have columns: vin, make, model, year, transmission, color and few more.

how do i make it so that when user lets say searches
make: ford
model: focus
year: 2002

he gets the results

or when he just puts ford in, gets all the fords.. and etc......
 
you'll need to build a query string based on the input provided.

for the 3 inputs you want the query string to be

select * from car_inventory where make = 'ford' and model = 'focus' and year = 2002



for just fords

select * from car_inventory where make = 'ford'
 
In the case of :

Code:
select * from car_inventory where make = 'ford' and model = 'focus' and year = 2002

does a multi-part query like that need parentheses, office ? I was studying a tutorial and I thought it said you did. Maybe it was a different use of SQL other than MySQL, I don't remember.

Would it be like ....

Code:
select * from car_inventory where (make = 'ford' and model = 'focus' and year = 2002)

EDIT: I answered my own question. Nope, I was wrong. I was thinking of a combined query like the one found here

To the OP, this site is a good one for SQL basics. I like it anyway >> SQL Syntax
 
Status
Not open for further replies.
Back
Top Bottom