Bind multiple query into single query

$conn = mysqli_connect("localhost", "mytutorial", "funtoofun", "tutorialdb");
$sqlquery = "select * from menu where pid = '".$parent_id."' and fki_status = '1' and pki_id NOT IN (select fki_id from menupermissions where fki_role !='".$role."')";

if($EmpNumber !=''){
$sqlquery .= "Union select * from menu where pid = '".$parent_id."' and fki_status = '1' and pki_id IN (select fki_id from menupermissions where fki_emp_number ='231')";
}
if($EmpDesig !=''){
$sqlquery .= "Union select * from menu where pid = '".$parent_id."' and fki_status = '1' and pki_id IN (select fki_id from menupermissions where fki_desig_id ='developer')";
}
if($EmpDepID !=''){
$sqlquery .= "Union select * from menu where pid = '".$parent_id."' and fki_status = '1' and pki_id IN (select fki_id from menupermissions where fki_dep_id ='IT02')";
}
if($DepType !=''){
$sqlquery .= "Union select * from menu where pid = '".$parent_id."' and fki_status = '1' and pki_id IN (select fki_id from menupermissions where fki_dep_type ='ittutorial')";
}
if($parent_id==0){
$sqlquery .= " order by sequence";
}


$result = mysqli_query($conn,$sqlquery);
$count = mysqli_num_rows($result);
if($count > 0) {
while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
{


}

}





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here


Ittutorial