<?php
include "config.php";
if (isset($_POST['update'])) 
    {
        
        extract($_POST);
 $abc=mysqli_query($connect,"select * from tbl_student_occupation where fld_occupation='".$_POST['occupation']."' and fld_occ_id!='".$_POST['occupation']."'and fld_occupation_delete='0'");

    if(mysqli_num_rows($abc)==1)
    {
       
       
            echo '<script type="text/javascript">'; 
            echo 'alert("Occupation Is Already Exist");';
            echo "window.location.href = 'view_stud_occupation.php';";
            echo '</script>'; 
           

        }    
        else
        {

            $query="Update tbl_student_occupation set fld_occupation='".$occupation."' where fld_occ_id='".$_GET['fld_occ_id']."' ";
            //echo $query."<br>";
            $row=mysqli_query($connect,$query) or die(mysqli_error($connect));
            if ($row) 
            {
                echo "<script>";
                echo "alert('Occupation Updated Successfully');";
                echo "window.location.href='view_stud_occupation.php';";
                echo "</script>";                 
            }
            else
            {
                echo "<script>";
                echo "alert('Occupation Not Update.);";
                echo "window.location.href='view_stud_occupation.php';";
                echo "</script>";
            }
        }    
    }
?>