Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » HELP - php mysql db search from form input
Closed Thread
Old 05-01-2009, 09:46 AM   #1 (permalink)
ibexpiotr's Avatar
 
True Techie

Join Date: Nov 2003

Posts: 197

ibexpiotr is on a distinguished road

Send a message via AIM to ibexpiotr
Default HELP - php mysql db search from form input

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......
ibexpiotr is offline  
Old 05-10-2009, 05:48 PM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default Re: HELP - php mysql db search from form input

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'
office politics is offline  
Old 05-10-2009, 05:58 PM   #3 (permalink)
oldskool's Avatar
 
Electrical Systems Design

Join Date: Jun 2008

Location: Maine, USA

Posts: 1,646

oldskool has a spectacular aura aboutoldskool has a spectacular aura about

Default Re: HELP - php mysql db search from form input

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

Last edited by oldskool; 05-10-2009 at 06:07 PM.
oldskool is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A Guide to Installing Apache, PHP, MySQL, and PHPMyAdmin on Windows CrazeD Programming Discussions 17 06-17-2009 04:27 PM
php sorting mysql db using html form variable ibexpiotr Programming Discussions 1 04-28-2009 11:14 AM
PHP - Search for "X" in multiple PHP files Mathias Programming Discussions 1 09-13-2008 04:35 PM
Looking for php form input and display script linux1880 Programming Discussions 3 06-03-2008 10:23 PM
Calling all PHP and MySql experts murdocsvan Programming Discussions 4 04-17-2008 01:51 PM