Forums

This topic is locked

Search page problems

Posted 13 Nov 2007 04:26:44
1
has voted
13 Nov 2007 04:26:44 Ray Smith posted:
Hello all. I'm going to cut and paste a small section of my code and i'll try to explain what i would like to do. I've got a search page with 4 viables being passed to the results page. I'v got my search working BUT i need a way to check if the variable is blank or not used on the search page so it doesnt effect my search results. So lets say if roomnumber is not used then it should not be part of the search string. I"m using Dreamweaves CS3 and coldfusion 8. Here is my code.

<cfparam name="FORM.roomnumber" default="">
<cfparam name="FORM.buildingnames" Default="">
<cfparam name="FORM.paintcode" Default="">
<cfparam name="FORM.buildingblocks" default="">
<cfquery name="Recordset1" datasource="paintshopcps">

SELECT *
FROM paintinfo
WHERE roomnumber LIKE <cfqueryparam value="#FORM.roomnumber#" cfsqltype="cf_sql_clob">
AND buildingnames LIKE <cfqueryparam value="#FORM.buildingnames#" cfsqltype="cf_sql_clob">
AND buildingblock LIKE <cfqueryparam value="#FORM.buildingblocks#" cfsqltype="cf_sql_clob">
AND paintcode LIKE <cfqueryparam value="#FORM.paintcode#" cfsqltype="cf_sql_clob">

I do realize that the AND, OR statments here mess up my search string but i cant figure out how else to do it. I'm very new to MYSQL so any pointing in the right direction would be great. Thanx all

Reply to this topic