I'm doing my first Search utility:
http://hhp.umd.edu/studentservices/internships.cfm

I'm trying to build a WHERE clause in CF where it check to see if a 
form field is part of a search and if it is, then it builds into the 
WHERE string.  Unfortunatley when I do, I get the error, "SQL command 
doesn't end properly" after clicking Search.

Here's some of the code:

<cfif structKeyExists(Form,"service_population") OR 
structKeyExists(Form,"agency") OR structKeyExists(Form,"city") OR 
structKeyExists(Form,"state") OR 
structKeyExists(Form,"salary_status")>

    <cfoutput>
  <--- setup a search --->
    <cfset find_text = "WHERE ">
    <cfif structKeyExists(Form,"service_population")>
       <!--- <cfset find_text ="WHERE service_population='children'">--->
       <cfset find_text 
="#find_text#service_population='#Form.service_population#'">
    </cfif>

    <cfquery name="getSearchItem" datasource="dpch">
       SELECT service_population,agency,city,state,salary_status
       FROM internships
       #find_text#
       ORDER BY agency ASC
    </cfquery>

    </cfoutput>
<cfelse>
  <--- setup some presets --->
    <cfset service_population = ''>
    <cfset agency = ''>
    <cfset city = ''>
    <cfset state = ''>
    <cfset salary_status = ''>

</cfif>


Also, if someone can just point me to a tutorial on this, then that'd be fine.
Really, any help would be appreciated.

-- 
Daniel Kessler

Department of Public and Community Health
University of Maryland
Suite 2387 Valley Drive
College Park, MD  20742-2611
301-405-2545 Phone
www.phi.umd.edu

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the mailserver that powers this list at 
http://www.houseoffusion.com/banners/view.cfm?bannerid=17

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189823
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to