homepage Welcome to WebmasterWorld Guest from 54.167.41.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Multiple parameter search MySQL/ PHP query
muya




msg:3304100
 9:23 am on Apr 6, 2007 (gmt 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.

 

brucec




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

Muya,
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.

Bruce

ahmedtheking




msg:3304228
 1:30 pm on Apr 6, 2007 (gmt 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!

muya




msg:3304258
 2:15 pm on Apr 6, 2007 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved