<?php
include "connect.php";

$kd_mtk=$_COOKIE['kd_mtk'];
$semester=$_COOKIE['semester'];
$ta=$_COOKIE['ta'];

$ceknilai =mysqli_query($koneksi,"select * from krs where kd_mtk='$kd_mtk'
 and semester='$semester' and ta='$ta'");
$hasil = mysqli_num_rows($ceknilai);

$nilai =$_POST['nilai'];
$nim =$_POST['nim'];
$jumdat = $_POST['id'];
$jumlah = count($jumdat);
//$status = "UNREG";
//Simpan data Nilai
for ($i=1;$i<= $jumlah;$i++)
{
 mysqli_query($koneksi,"update krs set nilai= '$nilai[$i]' where kd_mtk='$kd_mtk' and
 semester ='$semester' and ta='$ta' and nim='$nim[$i]'");
 
// update status mhs
 //mysql_query("update mhs set status= '$status' where nim='$nim[$i]'");
}
//Tampil DAta
echo"
<table border=1>";
echo "
<tbody>
<tr>
<td colspan=4>Kode Matakuliah : $kd_mtk
";
echo "Semester : $semester
";
echo "ta : $ta</td>
</tr>
";
?>
<tr>
<th> No.</th>
<th> Nim</th>
<th> Nama Mahasiswa</th>
<th> Nilai</th>
</tr>
<?php
include "connect.php";
$sqlkrs= mysqli_query($koneksi,"select * from krs,mtk,mhs where krs.nim=mhs.nim and
 krs.kd_mtk='$kd_mtk'
 AND krs.kd_mtk = mtk.kd_mtk
 AND krs.semester = '$semester' AND krs.ta='$ta' ORDER BY mhs.nim ASC");
$i=1;
while($datakrs=mysqli_fetch_array($sqlkrs)){
 echo"
<tr>
<td>$i</td>
";
 echo"
<td>$datakrs[nim]</td>
";
 echo"
<td>$datakrs[nm_mhs]</td>
";
 echo"
<td>$datakrs[nilai]</td>
</tr>
<tr>";
$i++;
}
?></tr>
<tr><td>
<a href="formnilai.php">Home</a>
</td></tr>
</tbody>
</table>

