|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using the <cfelse> method
Hi all,
I've got a piece of code that i can't get to work, maybe one of u can check it out? <cfquery name="tekst" datasource="spirilog"> <cfif #URL.tekst# EQ "tekst"> SELECT tekst FROM onderwerpen WHERE Id = #URL.Id# <cfelse> SELECT tekstvertaald FROM onderwerpen WHERE Id = #URL.Id# </cfif> </cfquery> Can anyone help ? |
|
#2
|
|||
|
|||
|
the <cfelse> method isn,t working so that's the question, how can i make it work?
|
|
#3
|
|||
|
|||
|
Boolean logic can be strange if you aren't familiar with it. First, this:
<cfif #URL.tekst# EQ "tekst"> ... <cfelse> ... </cfif> Can just be this (you don't need the extra pound signs): <cfif URL.tekst EQ "tekst"> ... <cfelse> ... </cfif> OK, so the only time the code within the <cfelse> block will execute is if the condition specified in the <cfif> block is false. So in this case, it will only ever run when URL.tekst does NOT equal "tekst". You can do a test to force this to happen by running: <cfset url.tekst = "No way does this say 'tekst'!!!" /> <cfquery name="tekst" datasource="spirilog"> <cfif URL.tekst EQ "tekst"> SELECT tekst FROM onderwerpen WHERE Id = #URL.Id# <cfelse> SELECT tekstvertaald FROM onderwerpen WHERE Id = #URL.Id# </cfif> </cfquery> The <cfelse> condition must fire in the above case.
__________________
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 |
|
#4
|
|||
|
|||
|
Hi, sorry for my late answer thanks for your help in this, works perfect
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Using the <cfelse> method |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|