SunQuest
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 7th, 2004, 03:57 PM
Global777 Global777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 6 Global777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Pulling results from 1 Text field and 2 Select Lists

I am trying to allow for selecting from a text box and two drop down lists. An individual could type in any part of a Last Name and select one choice from each of two Select lists. The result set should determine only those results that apply to each of the choices.

The three fields, LName, County, and Practice are all in the same table.

The results are coming back accurately when I submit one field but not when I submit two or more.

I am probably missing something very obvious to everyone but any help would be appreciated.

<!--- Get Lawyer list from database --->
<CFQUERY NAME="LocateLawyer" DATASOURCE="Lawyer">
SELECT *
FROM tblLawyers
WHERE 0=0

<!--- Search by last name --->
<CFIF FORM.LName IS NOT "">
AND LName LIKE '%#FORM.LName#%'
</CFIF>

<!--- Search by county --->
<CFIF FORM.County IS NOT "">
AND County1 LIKE '%#FORM.County#%'
OR County2 LIKE '%#FORM.County#%'
OR County3 LIKE '%#FORM.County#%'
OR County4 LIKE '%#FORM.County#%'
</CFIF>

<!--- Search by practice --->
<CFIF FORM.Practice IS NOT "">
AND Practice1 LIKE '%#FORM.Practice#%'
OR Practice2 LIKE '%#FORM.Practice#%'
OR Practice3 LIKE '%#FORM.Practice#%'
OR Practice4 LIKE '%#FORM.Practice#%'
</CFIF>
ORDER BY LName
</CFQUERY>

Reply With Quote
  #2  
Old August 8th, 2004, 03:26 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Try wrapping each set of WHERE criteria in parenthesis to ensure that the database is dealing with each one as it's own unit...something like this maybe:

<!--- Get Lawyer list from database --->
<CFQUERY NAME="LocateLawyer" DATASOURCE="Lawyer">
SELECT *
FROM tblLawyers
WHERE 0=0

<!--- Search by last name --->
<CFIF FORM.LName IS NOT "">
AND (LName LIKE '%#FORM.LName#%')
</CFIF>

<!--- Search by county --->
<CFIF FORM.County IS NOT "">
AND (County1 LIKE '%#FORM.County#%'
OR County2 LIKE '%#FORM.County#%'
OR County3 LIKE '%#FORM.County#%'
OR County4 LIKE '%#FORM.County#%')
</CFIF>

<!--- Search by practice --->
<CFIF FORM.Practice IS NOT "">
AND (Practice1 LIKE '%#FORM.Practice#%'
OR Practice2 LIKE '%#FORM.Practice#%'
OR Practice3 LIKE '%#FORM.Practice#%'
OR Practice4 LIKE '%#FORM.Practice#%')
</CFIF>
ORDER BY LName
</CFQUERY>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Pulling results from 1 Text field and 2 Select Lists


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway