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:
  #1  
Old April 7th, 2005, 01:15 PM
billrugen billrugen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 billrugen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 38 sec
Reputation Power: 0
trying to use 'or' for multiple drop downs

Hey,

I am trying to set up a selection where a user can choose from one or multiple drop downs and choose as many within a box as they want. works fine if you only choose from one column, but if you choose from two columns, the 'and' can create a bad match (for instance family may not be in that order, therefore nothing is returned). I would like the user to be able to choose several orders and perhpas a family not included in that list. I tried 'or,' but I am not sure how to begin this in that there needs to be an intial statement to attach the 'or's to, but if I do this, then I will also get that as part of the 'or'. I want to use 4 columns here eventually.

any help is greatly appreciated,
bill
here is the link http://161.55.120.152/ichweb/specframe.cfm

here is the code
<cfparam name="sortBy" default="PhylogenyCode">
<CFQUERY NAME="qryPhySelect" DATASOURCE="ichweb">
SELECT tblSpeciesDict.*
FROM tblSpeciesDict
WHERE tblSpeciesDict.gsid=tblSpeciesDict.gsid
<cfif isdefined ("Session.order")>
<cfif Session.order is not "">
<!--- preservesinglequote and session needed to pass string of phylogeny to taxa list. session. is session variable set in SetVariable.cfm --->
AND tblSpeciesDict.order in (#PreserveSingleQuotes(Session.order)#)
</cfif>
</cfif>
<cfif isdefined ("Session.family")>
<cfif Session.family is not "">
AND tblSpeciesDict.family in (#PreserveSingleQuotes(Session.family)#)
</cfif>
</cfif>
ORDER BY #sortBy#
</cfquery>
<head>
<title>Phylogeny Search Results</title>
<link rel="stylesheet" type="text/css" href="iis2.css" title="default">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Language" content="en-us" />
<meta name="keywords" content="Ichthyoplankton, information, system, early, life, history, northeast, pacific, bering sea, gulf of alaska, washington, oregon, california, coast, fishery, atlas, key, fish, larvae, eggs, juveniles" />
</head>
<body id="list">
<h3>Sort list:<h3>
| <a href="SearchListPhy.cfm.cfm?sortBy=tblSpeciesDict.GSID">Alphabetically</a> | <a href="SearchListPhy.cfm.cfm?sortBy=PhylogenyCode">Phylogenetically</a> |
</h3>
<h3>Choose taxa</h3>
<cfif qryPhySelect.order is not "" or qryPhySelect.order is not "">
<cfoutput query = "qryPhySelect">
<a href="LHDataIll.cfm?GSID=#qryPhySelect.GSID#" target="SearchLH">
- #qryPhySelect.Genus# #qryPhySelect.Species#</a></div>
</cfoutput>
<cfelse>
<div>No taxa met the search criteria</div>
</cfif>

Reply With Quote
  #2  
Old April 7th, 2005, 01:41 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 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 15 h 25 m 55 sec
Reputation Power: 53
Looking at your example, you'll just have to try out different loops and parenthesis positions...something like:

select *
from myTable
where (firstField = '#form.choice#') OR (secondField = '#form.choice1#' OR secondField = 'form.choice2'#)

Good luck.

Brian
__________________
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

Last edited by kiteless : April 7th, 2005 at 01:44 PM.

Reply With Quote
  #3  
Old April 11th, 2005, 11:24 AM
billrugen billrugen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 billrugen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 38 sec
Reputation Power: 0
thanks.

problem there is I am want to use 4 sets of drop downs eventually and the code very complicated and kind of rube golbergian, it seems like there should be a more straight forward way of doing this. maybe not.

Reply With Quote
  #4  
Old April 11th, 2005, 03:33 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 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 15 h 25 m 55 sec
Reputation Power: 53
Not really...SQL isn't optimized for these sorts of long and complex where clauses. Remember that in many cases, what seems like it should be relatively simple can require a very complex SQL statement. You can fiddle with different loops and combinations of ORs and ANDs, or possibly look into doing full text indexing using Verity or some other text search tool.

Reply With Quote
  #5  
Old April 11th, 2005, 05:50 PM
billrugen billrugen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 billrugen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 38 sec
Reputation Power: 0
well, I think I may work with how I present the returned data then to avoid that code.

thanks for the info.

bill

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > trying to use 'or' for multiple drop downs


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
Stay green...Green IT