Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFIF STATEMENT - HELP

Status
Not open for further replies.

kingjjx

Programmer
Joined
Sep 18, 2001
Messages
181
Location
US
Hi, I have a query page that has a radio button to search for BIKES, AUTOS OR ALL

The field it is going to query from has a list of codes [1,2,3,4,5 . .etc]

I want to return BIKES if codes found are between 1-39
and return AUTOS if codes found is 40 and above
and return ALL products too as the third option.

I guess I could also just look for just the first code it finds, and if it is between 1-39, return BIKES and 40 and above return AUTOS.

How can I write this conditional statement?

thank you
 
<CFSET qstring=&quot;And (code='#Replace(codelist,&quot;,&quot;,&quot;' OR code='&quot;,&quot;ALL&quot;)#')&quot;>

<CFQUERY....>
select * from table
WHERE 0=0
#qString#
</CFQUERY>

Works for me... in one of my search engines.
 
Hi, you lost me there ...
Can you please explain your answer a little further.
Im not really that deep into ColdFusion yet.
Im a newbie

thanks
-jon
 
<CFSET bqstring=&quot;And (code='#Replace(bikecodelist,&quot;,&quot;,&quot;' OR code='&quot;,&quot;ALL&quot;)#')&quot;>
<CFSET cqstring=&quot;And (code='#Replace(carcodelist,&quot;,&quot;,&quot;' OR code='&quot;,&quot;ALL&quot;)#')&quot;>
<CFSET aqstring=&quot;And (code='#Replace(allcodelist,&quot;,&quot;,&quot;' OR code='&quot;,&quot;ALL&quot;)#')&quot;>

<CFQUERY....>
select * from table
WHERE 0=0
#bqString#
#cqString#
#aqString#
</CFQUERY>

This will get you all products with matching code ids.. I guess I just don't understand your question... if you want to get them all... that's how I suggest you do it.
 
Hey, hope this will give you a better idea of what im trying to do:

The search page will look like this:

SEARCH:

Auto Dyno [X]
Bike Dyno [ ]
All [ ]

The code for this will be something like this:

<INPUT type=radio CHECKED value=1 name=DynoCode>
AUTO DYNO
<INPUT type=radio value=2 name=DynoCode>
BIKE DYNO
<INPUT type=radio value=3 name=DynoCode>
ALL</center></p>


My table field looks like this:
PRODUCT CODE

PRODCUT A [ 2,4,5]
PRODUCT B [ 35,37]
PRODUCT C [ 44,48,49]
PRODUCT D [ ]

Now, I set the DynoCode value at 1,2 and 3 because I wanted to say something like:

If DynoCode is a 1 and the first number on the list is less than 40 then output the matching products

Else if the Dynocode is a 2, and the first number found on the list is 40 and above then output the matching proiducts

Else if dynocde is a 3 then output all products.


I actually want this to work with a dropdown list I created to query by state .. this way a customer can query by state and by product.

you can look at the page at: (page still does not work with the product query)


Well, hope this helps. I just need help in writing the actual code so i can mix this functionality with my search by location query.
thanks
 
If your still haveing problems with this, you might want to rethink the database / application design.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top