building a query string

Associate
Joined
4 Feb 2014
Posts
12
Code:
Guys, im having a wee problem when building a query string.

I have a search menu where the user selects options from a drop down menu and then this builds up the search query string. I have a Pass and Fail options from a drop down menu which work. I have changed it slightly now as a Pass can be any of the following: TS/Pass, NC/Pass or Mixed/Pass or it completely fails.

So now in my drop down have all of the above plus an overall Pass option, so it looks like: Pass, TS/Pass, NC/Pass, Mixed/Pass and Fail. I can now look explicitly for a NC/Pass now. But what my issue is that I want it so it I click on the Pass option it will search for TS/Pass, NC/Pass, Mixed/Pass results.

Can seem to get those 3 options strung together correctly.
Here is my code:
Code:
$QBuild = "";
$QBuild .= "SELECT * FROM ($table) WHERE($field)";

	if($Date1 && $Date2 != NULL){
		$QBuild .= "AND (Date BETWEEN '$Date1' AND '$Date2') ";
	}

	if($Initials != NULL){
		$QBuild .= "AND (Initials LIKE '$Initials')" ;
	}

	if($PassFail == 'Pass'){
		$QBuild .= "AND (PassFail LIKE 'TS/Pass' || 'NC/Pass' || 'Mixed/Pass')" ;
		}
		
		
		if($PassFail != NULL){
		$QBuild .= "AND (PassFail LIKE '$PassFail')" ;
		}
	
	if($circuit != NULL){
		$QBuild .= "AND (circuit LIKE '$circuit')" ;
	}

Thanks
 
Back
Top Bottom