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!

QUERYING IN BETWEEN 2 PREPOPULATED VALUES ? 1

Status
Not open for further replies.

kingjjx

Programmer
Joined
Sep 18, 2001
Messages
181
Location
US
hI, i am making a page to enable a user to query by MAKE, MODEL AND between First Year and Last Year chosen ..all these values are in a drop down menu populated from a database ..
**my question is how do i add the <CFIF statement in the action page ? my script is below:

************THIS IS THE SEARCH FORM (I ONLY PUT THE YEARX AND YEAR Y QUERY SINCE THE MAKE AND MODEL WORKS FINE ALREADY)**********

<SELECT name=&quot;SearchYear1&quot;>
<OPTION value=&quot;All&quot;>ALl
<CFOUTPUT QUERY=&quot;Searchdyno&quot;>
<option value=&quot;#FirstYear#&quot;>#FirstYear#</cfoutput>
</select> <br>

Last Year:
<SELECT name=&quot;SearchYear2&quot;>
<OPTION value=&quot;All&quot;>ALl
<CFOUTPUT QUERY=&quot;Searchdyno&quot;>
<option value=&quot;#lastyear#&quot;>#lastyear#</cfoutput>
</select>

****************THIS IS THE ACTION PAGE ***********
****************MY question is how do I add the <CFIF for the year so that it will return everything between Year1 to Year 2 ??**

<CFQUERY NAME=&quot;GetResults&quot; DATASOURCE=&quot;DynoRunEx&quot;>
SELECT * FROM RunData WHERE 1 =1
<cfif #form.SearchMake# NEQ &quot;All&quot;>
AND RunData.Make LIKE '%#SearchMake#%'
</cfif>
<cfif #form.SearchModel# NEQ &quot;All&quot;>
AND Rundata.Model LIKE '%#SearchModel#%'
</cfif>
</cfquery>
 
suggestion 1:

<cfif #form.FirstYear# NEQ &quot;All&quot; AND #form.lastyear# NEQ &quot;All&quot;>
AND Rundata.FirstYear > #Form.FirstYear# AND Rundata.lastyear < #Form.lastyear#
</cfif>

suggestion 2:

<cfif #form.FirstYear# NEQ &quot;All&quot; AND #form.lastyear# NEQ &quot;All&quot;>
AND Rundata.year BETWEEN #Form.FirstYear# AND #Form.lastyear#
</cfif> Sylvano
dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top