<?php
	include './connection.php';
	include 'header.php'; 
?>

 <!DOCTYPE html>
 <html>
 <head>
 	<title>Case Update</title>
 </head>
 <body>
 <h4 style="text-align: center;">Update Case here</h4>
<table style="width: 98%;text-align: center;border:1px solid navy">
 <tr style="background-color: darkgreen;color: white;">
		<th>مقدمہ نمبر</th>
		<th>رجوعہ</th>
		<th>عنوان مقدمہ</th>
		<th>نوعیت مقدمہ</th>
		<th>قسم</th>
		<th>Update</th>
	 
	</tr>
<?php
$cn="";
$cid=$_GET["id"];
    $q1="SELECT * FROM caseinfo WHERE ID='".$cid."'";
    $result=$conn->query($q1);
    if (!empty($result) && $result->num_rows > 0)
     {
 
while( $row=$result->fetch_assoc())
{
    echo '<form action="caseupdate_php.php?c=2" method="POST">   <tr >';
    echo '<input style="text-align:center;" type="hidden" name="cid" value="'.$cid.'">';
    echo '<td><input style="text-align:center;" type="text" name="caseno" value="'.$row["caseno"].'"></td>';
    echo '<td><input style="text-align:center;"   type="text" name="instdate" value="'.$row["instdate"].'"/></td>';

    echo '<td><input style="text-align:center;" type="text" name="title" value="'.$row["casetitle"].'"></td>';

  
     echo '  <td> <input type="text" name="casetype" value="'. $row["casetype"].'"  class="txt" > </td>';
 
 
 echo '<td><select name="casenature">';
 $cn=$row["casenature"];
 $id=$row["ID"];
 if($row["casenature"]==="1")
 {
 	echo '<option value="1">Civil</option><option value="2">Criminal</option>';
 }else{
echo '<option value="2">Criminal</option><option value="1">Civil</option>';
 }
echo '</select></td><td><input name="inf" type="submit" value="Update"></td>';
    echo "</tr></form>";
}
     }



       ?>




</table>
<br><br><br>

<?php

if($cn==="2")
{
    echo '<table style="width: 98%;text-align: center;border:1px solid navy"><tr  style="background-color: navy;color: white;"><th>FIR No</th><th>Police Station</th><th>FIR Date</th><th>Update</th></tr>';
    $nq="SELECT * FROM tbl_criminal WHERE case_id='".$id."'";
    
   $r=$conn->query($nq);
  $row1=$r->fetch_assoc();
       echo '<form action="caseupdate_php.php?c=1" method="POST"><tr><td><input type="text" value="'.$row1["fir_no"].'" name="fno"></td><td><input type="text" value="'.$row1["ps"].'" name="fps"></td><td><input value="'.$row1["fir_date"].'" name="fdate"></td><td><button name="inf1">Update</button></td>';
       
        echo '<input style="text-align:center;" type="hidden" name="id" value="'.$_GET["id"].'"> </form></tr>';
   
    echo '</table>';
    
}

?>
 </body>

 </html>