My code is here

$location="Delhi,NOIDA";
$cheack2 = "";
$arr=array();
$flag = false;
 if(isset($skill)&&$skill != ""){
  $query_arr = explode(",",$skill);
  foreach($query_arr as $query_arr2)
  {

      $arr[] = "job_keyskills like '%$query_arr2%' ";
  }

    $cheack2=implode(" OR ",$arr);
     $flag =true;
 }

    if(isset($skill)&&$skill != ""){
    if($flag){
    $cheack2.= "OR ";
}

 $cheack2.="MATCH (job_keyskills,job_title)
 AGAINST ('+$skill' IN BOOLEAN MODE) ";
 $flag =true;
}



if(isset($location)&&$location != ""){
    if($flag){
    $cheack2.= "AND ";
}
    $loc = explode(",",$location);
    foreach($loc as $loc2)
    {

 $arr[]="job_location like '%$loc2%' ";
 $flag =true;
}
 $cheack2=implode(" OR ",$arr);
 $flag =true;
}

select * from tb_job where 1=1 and job_keyskills like '%PHP%' OR job_keyskills like '%PHP Programmer%' OR job_location like '%Delhi%' OR job_location like '%Chhattisgarh%'

But i want this type of query

select * from tb_job where 1=1 and job_keyskills like '%PHP%' OR job_keyskills like '%PHP Developer%' AND job_location like '%Delhi%' OR job_location like '%NOIDA%'

Assuming, you want search your database with multiple values (from the title) & want to correct the sql query you have written (in the last line). Here is the solution.

SELECT * FROM tb_job WHERE (job_keyskills='PHP' OR job_keyskills='PHP Developer') AND (job_location='Delhi' OR job_location='NOIDA');

Hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.