I am picking values from which are seperated by a comma in the following format:
value1,value2,value3
I then pass the values into a query such that if the value was only one the query would be:
$sql="select vacancy from jobs where vacancy='$value1'";
If it was more then one value then it would be:
$sql="select vacancy from jobs where vacancy='$value1' or '$value2' or '$value3'";
The number fo values may vary depending on what the user has selected, I have written the following code but am having a problem with the last OR statement.
$arrPosition=explode(",",$position);
if(sizeof($arrPosition)>1){
foreach($arrPosition as $val){
//echo $val." or ";
$val.=" OR ";
$sql="select vacancy from jobs where vacancy=$val";
//getApplicantsByDate($vacancy=$val,$startdate,$enddate);
}
}else{
$sql="select vacancy from jobs where vacancy=$position";
}
Unfortunately when the value is more then one it prints out the following sql:
"select vacancy from jobs where vacancy='cook' OR 'guard' OR ";
resulting in error, any help from you guys would really be good..
Cheers