Search Database, return records

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
JoeSchmoe
Forum Newbie
Posts: 2
Joined: Sat Jul 20, 2002 6:58 pm

Search Database, return records

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
JoeSchmoe
Forum Newbie
Posts: 2
Joined: Sat Jul 20, 2002 6:58 pm

Post 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?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply