                    <?php 
require_once '../system/conn.php';
                      $cnt = 1;
                      $stmt1 = $conn->prepare(" SELECT `e_id`,`branch`,`e_doj` from `emp_details` where `status`='0'  ");
                      $stmt1->execute();
                      $sql = $stmt1->fetchAll();
                      foreach($sql as $row2) 
                      { 
                       $e_id= $row2['e_id']; 
                       $branch= $row2['branch']; 
                       $entry_date= $row2['e_doj']; 
                       $status='1';
                       $dol=date("Y-m-d");
                       
                       $i = 1;
                       $stmt2 = $conn->prepare(" SELECT * from `left_employee` ");
                       $stmt2->execute();
                       $sql2 = $stmt2->fetchAll();
                       //print_r($sql2);exit;
                       foreach($sql2 as $row3) 
                       { 
                        if($e_id!=$row2['emp_id'] && $branch!=$row2['branch'] &&  $entry_date!=$row2['entry_date'] ) {
                            
                            
                             $j = 1;
                             $stmt3 = $conn->prepare(" SELECT `e_id`,`branch`,`e_doj` from `emp_details` where `status`='0'  ");
                             $stmt3->execute();
                             $sql3 = $stmt3->fetchAll();
                             foreach($sql3 as $rowss) 
                             { 
                               echo $e_id= $rowss['e_id']; 
                             $j=$j+1; }     
                            
                        
                           /*$query = "INSERT INTO `left_employee` (emp_id, d_o_l, entry_date, branch, status) VALUES  ('$e_id', '$dol', '$entry_date', '$branch', '$status') ";
                           //print_r($query);exit;
                           $statement = $conn->prepare($query)->execute();
                           
                           if($statement){
                               echo "<script>alert('Employees moved to left employees successfully.')</script>";
                               echo " <script>window.location.assign('move-to-leftemp.php')</script>";
                           } else {
                              echo "Not updated";
                           }*/
                           
                           
                           
                        } else {
                            echo "<script>alert('No data found.')</script>";
                            echo " <script>window.location.assign('move-to-leftemp.php')</script>";
                        }
                        $i=$i+1; } 
                      $cnt=$cnt+1; }
                    ?>