<?php include "header.php"; 
if($login_type=='admin'){
$btnSave=$_POST['btnSave'];
$name=$_POST['name'];


if($btnSave=='Add Record'){
$query = "INSERT INTO `student_type` (`id`, `name`,`code`) VALUES ('$id','$name','$code')";
  mysql_query( $query )
 or die ( "Couldn't add data to \"application\" table: " 
 .mysql_error() );
print "<div>Data Save [ ". mysql_affected_rows() .
" row(s) ] Successfully </div>";
?>
<script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_student_type.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?PHP
}





$submit=$_GET['submit'];
if($submit=='Delete'){
$id=$_GET['id'];
$query = "DELETE FROM student_type WHERE id='$id' and code='$code'";
$result = mysql_query( $query );
if ( ! $result )
die ("Couldn't deleted: ".mysql_error());
print "<h1>Table deleted ". mysql_affected_rows() .
" row(s) deleted</h1><p>";
?>
<script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_student_type.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?PHP
}
?> <section class="content">
      <div class="container-fluid">
                <!-- Page Header -->
                <div class="col-lg-12">
                   
    
<script language='JavaScript'>

function validate()
{
	conf = confirm("Are you sure you want to delete?");
	if (conf)
		return true
	else
		return false;
}

</script><div class="card card-danger">
              <div class="card-header">
                <h3 class="card-title"><?php echo $_GET['title']; ?>?</h3>
              </div>


    
      <form name="form1" action="feed_student_type.php" method="post"  class="form-horizontal" role="form">
	  <table cellpadding=2 cellspacing=0 border=1 bordercolor=#FFFFCC bgcolor="" align=center class="table table-bordered table-striped">
				
		
		<tr>
		  <td width="116" class=color3>Student Type</td>
		  <td width="190" class=color2><input class="form-control" name="name" type="text" class="form-control" required="required" /></td>
		</tr>
        <tr>
          <td class=color3></td>
          <td class=color2>&nbsp;</td>
        </tr>
        <tr> 
			<td class=color3></td>
			<td class=color2><input class="btn btn-primary" type="submit" name="btnSave" value="Add Record"  class="btn btn-info" ></td>
		</tr>
	</table>
</form>
<?php
	 
$query = "SELECT * FROM student_type where code='$code' ORDER BY name";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");


?>
<div style="overflow:auto; text-align:center">
<div class="card card-success">
              <div class="card-header">
                <h3 class="card-title"><?php echo $_GET['title']; ?>?</h3>
              </div>
<?php if($numrows!=""){?>
   <table  cellpadding="1" border="1" cellspacing="1" bgcolor="" align="center" class="table table-bordered table-striped">
 <tr>
	
 <td align="center" valign="top"  class="border"><div align="center"   ><em><strong>S.</strong></em></div></td>
  <td align="center" valign="top"  class="style1" >Student Type</td>
  <td align="center" valign="top"  class="border"><div align="center"    ><em><strong>Delete</strong></em></div></td>
 </tr>
<?php 
$counter = 1;?>
 <?php
while ( $a_row = mysql_fetch_row( $result ) )
 {?>
 
 

 <tr>
 <td height="20" align="center" valign="top" ><div align="center" ><?php echo $counter;?></div></td>
 <td bordercolor="#FFFFCC" class=color2><?php echo $a_row[1]; ?></td>
 <td align="center" valign="top" >

 
<a href="feed_student_type.php?id=<?php echo $a_row[0];?>&&submit=Delete" onclick='return validate();'><input type="reset" class="btn btn-danger" name="Delete" value="Delete" class="btn btn-danger" /></a></td>
 </tr>


   
  <?php $counter++;}?>
  </table>
</div>
   <?php }?>

<?php if($numrows==""){
  echo "<div  style='border:none; text-align:center'><h3 class='logo2'>No Record Found</h3></div>";
}?>
        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>

<?php } include "footer.php"; ?>