Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Multiple parameter search MySQL/ PHP query

9:23 am on Apr 6, 2007 (gmt 0)

New User

10+ Year Member

joined:Aug 6, 2005
votes: 0

Hi all,
I know this question has been posed before, but as a newbie at server-side scripting, I'm having a problem making head or tail of the various posts I have perused.
My problem is how to make a search form with multiple fields, connected to a database with several tables, work. I'm using Dreamweaver for the coding, but I'd like to understand the coding - both PHP and MySQL.
As I say I've looked through several threads listed below, but I cannot tell whether any of them deal with the multiple fields I am coding.
I would like a visitor to search through the database without necessarily filling-in or making selections, from all the fields in the search form (most of them are list/menus).
I have no problem with the basic mysql coding (connections etc) - Dreamweaver takes care of that. It's how to code the actual fields such that only the specific search-query/results that the visitor makes are displayed.
The threads I've looked through are:
  1. [webmasterworld.com ]
  2. [webmasterworld.com ]
  3. [webmasterworld.com ]

The last is the most relevant, but as I say, I need a walk through.

Thanks in advance for any help you can give me.

1:28 pm on Apr 6, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Jan 23, 2004
votes: 0

It depends on what data type your database fields are.

If the user is searching for text in a VARCHAR or CHAR field, use a LIKE clause in your MySQL:

select * from TABLE where Searched_Field LIKE '%$_GET[Keyword]%'

Don't forget to use the percent signs as they turn your WHERE clause into a subset, which is probably what you want anyway.


1:30 pm on Apr 6, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 12, 2004
posts: 789
votes: 0

Ok so you want a non-type site navigation yeah? Sort of like a multi jump box? Or have I got it wrong? Well if I haven't, this is how I'd do it:

You mentioned you had several tables, so let's say, for arguments sake, each ones is a category to the other. So you start with:

X1, X2, X3. They then lead to X11, X21, X31 and you can see what I'm getting at.

What you can do is get PHP to write the HTML for these search boxes and when a parent is picked by the user, using JavaScript such as script.aculo.us (http://script.aculo.us/), you can create a nice Js interface so that as the user clicks on a category, the relevant menu pops up next and so on. I hope that makes sense!

2:15 pm on Apr 6, 2007 (gmt 0)

New User

10+ Year Member

joined:Aug 6, 2005
votes: 0

Thanks guys for your early replies.
I have a combination of datatypes - varchar, integers, images etc.
I've been looking at lots of scripts, so I'll go through them over the weekend, and come back with more detail.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members