<html>
<head>
<title>LAP MHS</title>
<style type="text/css">
<!--
.style1 {
	color: #FF0000;
	font-style: italic;
}
.style4 {color: #FF0000}
-->
</style>
</head>
<body>
<?
	include "connect.php";
	session_start();

//cek apakah user sudah login


//cek level user
if($_SESSION['Level']=="baak" || $_SESSION['Level']=="admin" || $_SESSION['Level']=="kmhs"){

	$seleksi = "";

if (isset($_POST['ctingkat']))
{
   $tingkat = $_POST['tingkat'];
   if (empty($seleksi))
   {
		$seleksi .= "tingkat LIKE '$tingkat'";
   }
}

if (isset($_POST['ckelas']))
{
   $kelas = $_POST['kelas'];
   if (empty($seleksi))
   {
		$seleksi .= "kelas LIKE '%$kelas%'";
   }
   else
   {
        $seleksi .= " AND kelas LIKE '%$kelas%'";
   }
}

if (isset($_POST['cstatus']))
{
   $status = $_POST['status'];
   if (empty($seleksi))
   {
		$seleksi .= "status LIKE '$status'";
   }
   else
   {
        $seleksi .= " AND status LIKE '$status'";
   }
}

if (isset($_POST['cangkatan']))
{
   $angkatan = $_POST['angkatan'];
   if (empty($seleksi))
   {
		$seleksi .= "angkatan LIKE '$angkatan'";
   }
   else
   {
        $seleksi .= " AND angkatan LIKE '$angkatan'";
   }
}

?>
<h3><center> UPDATE KOLEKTIF TINGKAT, SEMESTER, STATUS (MHS) </h3>
<form method=post action=cnaik1.php>
<table width="983" border="1" align="center">
<tr>
<th width="144"> No</th>
<th width="145"> Nim</th>
<th> Nama</th>
<th width="63"> Tingkat</th>
<th width="51"> Kelas</th>
<th width="65"> Semester</th>
<th width="65"> Angkatan</th>
<th width="79"> Status</th>
</tr>
<?php
	$hasil=mysqli_query($koneksi,"select * from mhs where $seleksi");
	$total= mysqli_num_rows($hasil);
	
 $no=1;
 if ($total){
		while ($row=mysqli_fetch_array($hasil))
		{
?>
<tr>
<td> <input name="id[<? echo $no; ?>]" type="text" value="<? echo $no; ?>" /></td>
<td><input name="nim[<? echo $no; ?>]" type="text" value="<? echo $row[0]; ?>" /></td>
<td width="319"><a href="viewmhs.php?idv=<? echo $row[0]; ?> " style="text-decoration:none"><? echo $row[1]; ?></td>
<td> <? echo $row[2]; ?>
<td> <? echo $row[3]; ?>
<td> <? echo $row[4]; ?>
<td><? echo $row[14]; ?>
<td><? echo $row[15]; ?></td>

<?php
$no++;
}
}
?>
<tr>
<td colspan="3"><span class="style1">Pastikan semua kolom</span> <em><strong>[Tingkat, Semester, Status]</strong> <span class="style4">terisi!!</span></em>
  <select name ="tingkat">
        <option selected>Tingkat</option>
        <option>1</option>
        <option>2</option>
        <option>3</option>
      </select>
  <select name ="semester">
        <option selected>Semester</option>
        <option>0</option>
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
        <option>6</option>
      </select>
  <select name ="status">
        <option selected>AKTIF</option>
        <option>AKTIF</option>
        <option>UNREG</option>
        <option>CUTI</option>
        <option>DO</option>
        <option>ALUMNI</option>
      </select>
  <input type="submit" value="Update" >
  <input type="reset" value="Cancel" ></tr>
</table>
</form>
<?php
} else {
    die("Anda bukan admin");
}
?>
</body>
</html>