Search function using multiple criteria?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
richmix
Forum Commoner
Posts: 31
Joined: Fri Dec 22, 2006 5:21 am

Search function using multiple criteria?

Post by richmix »

Hi all, I'm trying to write a search function using multiple criteria that will display all relevant results from the database, but I want to keep each field optional. I'm trying to do the SELECT statements without using a crapload of if (isset($varblah)) statements. I know I could use a switch, but again, I'd have to account for every permutation of the form fields. So, can anyone help me out here?

I'm sure this is a basic thing, but I can't sort it out. Any help would be appreciated.
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

I'm assuming you're usin mysql. In that case you should check out FULLTEXT index. It'll make your life much easier.

http://www.databasejournal.com/features ... hp/1578331
http://www.petefreitag.com/item/477.cfm
http://jeremy.zawodny.com/blog/archives/000576.html
richmix
Forum Commoner
Posts: 31
Joined: Fri Dec 22, 2006 5:21 am

Post by richmix »

wtf wrote:I'm assuming you're usin mysql. In that case you should check out FULLTEXT index. It'll make your life much easier.

http://www.databasejournal.com/features ... hp/1578331
http://www.petefreitag.com/item/477.cfm
http://jeremy.zawodny.com/blog/archives/000576.html
Some of my fields are INT. Will I just have to do manual ifs or switches for the INT fields? (I want the user to be able to input a min/max price and show the results that are between those fields.)

Thanks for the help. FULLTEXT will be useful for a big part of this.
Post Reply