Skip to main content
April 19, 2011
Answered

ColdFusion If Statements

  • April 19, 2011
  • 1 reply
  • 1154 views

Hi there,

Is there a way of setting a cfif statement to use GT and LT and the same time i want it to be GT 4 but LT 7

Thanks

Jonathan

    This topic has been closed for replies.
    Correct answer JMF3

    <cfif myVal gt 4 and myVal lt 7

    1 reply

    JMF3Correct answer
    Participating Frequently
    April 19, 2011

    <cfif myVal gt 4 and myVal lt 7

    April 19, 2011

    Hi mate yeah that works thanks very much

    got a new problem now i get this error when it gets to the last CFIF when 4 or GT.

    Error Occurred While Processing Request 
    Element TWIN is undefined in FROM.

    only come up when it runs the last cfif any ideas

    <cfparam name="FORM.twin" type="string" default="0" />
    <cfparam name="FORM.double" type="string" default="0" />
    <cfparam name="FORM.family" type="string" default="0" />
    <cfparam name="FORM.suite" type="string" default="0" />
    <cfparam name="FORM.penthouse" type="string" default="0" />
    <cfparam name="FORM.nights" type="string" default="0" />
    <cfparam name="FORM.checkin" type="string" default="0" />
    <cfparam name="FORM.guests" type="string" default="0" />

    <cfquery name="twin" datasource="strand">
    SELECT *
    FROM hotel_rooms
    WHERE hotel_rooms.ID = 1</cfquery>

    <cfquery name="double" datasource="strand">
    SELECT *
    FROM hotel_rooms
    WHERE hotel_rooms.ID = 2</cfquery>

    <cfquery name="family" datasource="strand">
    SELECT *
    FROM hotel_rooms
    WHERE hotel_rooms.ID = 3</cfquery>

    <cfquery name="suite" datasource="strand">
    SELECT *
    FROM hotel_rooms
    WHERE hotel_rooms.ID = 4</cfquery>

    <cfquery name="penthouse" datasource="strand">
    SELECT *
    FROM hotel_rooms
    WHERE hotel_rooms.ID = 5</cfquery>

    <cfif form.twin eq "1">
    <cfset price = 1*#twin.price_night1#>

    <cfelseif form.twin eq "2">
    <cfset price1 = 2*#twin.price_night1#>
    <cfset price = #price1#*0.95>

    <cfelseif form.twin eq "3">
    <cfset price1 = 3*#twin.price_night1#>
    <cfset price = #price1#*0.90>

    <cfelseif form.twin gte "4" and form.twin lt "7">
    <cfset price1 = #from.twin#*#twin.price_night1#>
    <cfset price = #price1#*0.85>

    </cfif>

    Inspiring
    April 19, 2011
    Element TWIN is undefined in FROM.

    Read the error message (and your code) more closely.

    --

    Adam