Skip to main content
Participant
March 30, 2008
Answered

Help with multiple parameter search recordset

  • March 30, 2008
  • 8 replies
  • 586 views
I have a mysql table being searched by two fields City and State
using dreamweaver, I have set up a form with a text field as city and a list as state and I have them being passed with the get method.
The problem is on the results page, I have a recordset SELECT * FROM table name. What do I do with the WHERE, I have tried multiple configurations, and I can't get anything to work. I only want to search by two fields, city and state. The state has to match, but if the city is left blank, I still want to filter by state.

Can somebody help me or point me in the right direction, please?
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer bigleo23
Thank you, but I figured my problem out and I no longer need help.

8 replies

Inspiring
April 21, 2008
Hi Steve... Sorry for the long time in replyig... been away on business.

Anyway to answer your question, I would like the input field to accept all or part of a product name or description, and the dropdown list to narrow the search within a specifc category.

Thanks for the help.
Inspiring
April 16, 2008
SaigonJeff wrote:
> Oops... sorry!
>
> I'm using PHP / MySQL
>
> PHP 4.3.4
> MySQL 4.1
>
> Thanks for the help...

I was going to suggest a Stored Procedure approach, as that is how I
always approach filtering, but I use MS SQL, and I don't know if/how to
do it in MySQL.

The first part is fairly easy:

SELECT *
FROM yourTable
WHERE Column1 = MMColParam OR Column2 = MMColParam OR Column3 = MMColParam

Obviously this will match the entire value of MMColParam to the entire
value of any 3 of the columns. If you want to latch the value of
MMColParam to any part of the columns contents, you need to do this:

SELECT *
FROM yourTable
WHERE Column1 LIKE '%' + MMColParam + '%' OR Column2 LIKE '%' +
MMColParam + '%' OR Column3 LIKE '%' + MMColParam + '%'

This doesn't include the filter. How do you want to the filter to work?

Steve
Inspiring
April 15, 2008
Oops... sorry!

I'm using PHP / MySQL

PHP 4.3.4
MySQL 4.1

Thanks for the help...
Inspiring
April 15, 2008
SaigonJeff wrote:
> Yes... Please... I am having a similar problem but I am trying to search 3
> columns usinga form with a single text field and a dropdown menu to filter the
> catagory.
>
> Any ideas you could offer would be extremely appreciated.
>
> Thanks in advance.
>

What server side language are you using? What database are you using?

Steve
Inspiring
April 15, 2008
Yes... Please... I am having a similar problem but I am trying to search 3 columns usinga form with a single text field and a dropdown menu to filter the catagory.

Any ideas you could offer would be extremely appreciated.

Thanks in advance.
bigleo23Author
Participant
March 30, 2008
I also wanted it known that I am using php
bigleo23AuthorCorrect answer
Participant
March 31, 2008
Thank you, but I figured my problem out and I no longer need help.