Page 1 of 1

Search Database, return records

Posted: Sat Jul 20, 2002 6:58 pm
by JoeSchmoe
Hi, I'm new to PHP/MySQL and need help please.

Basically I need to know how http://uk.mobile.de/cgi-bin/search.pl?b ... &sprache=2 or http://www.car.gr can search their database and have the 'any make' or 'any mileage' option set. What is the code for something like this?

Deeply appreciated.

Posted: Sun Jul 21, 2002 6:03 am
by twigletmac
Probably an idea to look at some tutorials on MySQL and PHP. These are available in lots of places: to name but a few.

Mac

Posted: Sun Jul 21, 2002 7:28 am
by JoeSchmoe
Thanks, but I searched everywhere and all I can find is how to return records with a certain make. If I illustrate it, you may understand:

Fields: Make, Model, Color, Mileage

If I want to search make and model but leave the color and mileage as wildcards, then what is the php for it?

Posted: Sun Jul 21, 2002 10:26 am
by twigletmac
First off, you don't use PHP to search the database you use PHP to run SQL queries.

Have a look at the mysql information on select to see how to construct a basic query:
http://www.mysql.com/doc/S/E/SELECT.html

Basically you want to have some conditions in the WHERE clause of the SELECT statement.

Code: Select all

SELECT Make, Model, Color, Mileage FROM your_table WHERE Make = 'something' AND Model = 'something_else'
Mac