Page 1 of 1

Search function using multiple criteria?

Posted: Wed Dec 27, 2006 9:49 am
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.

Posted: Wed Dec 27, 2006 10:34 am
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

Posted: Wed Dec 27, 2006 10:52 am
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.