<?php
include"connect.php";
$idset="DIREKTUR";
	$hset= mysqli_query($koneksi,"select * from staf where jabatan='$idset'");
	$pset=mysqli_fetch_array($hset);
$nim= $_POST['nim'];
$semester= $_POST['semester'];
$ta = $_POST['ta'];
$krssql = mysqli_query($koneksi,"select * from krs where nim='$nim' AND semester='$semester' AND ta='$ta'");
$hasil=mysqli_num_rows($krssql);
if($hasil > 0 )
{
$mhssql = mysqli_query($koneksi,"select * from mhs where nim='$nim'");
$hasilmhs=mysqli_fetch_row($mhssql);
if ($hasilmhs)
{
if ($hasilmhs[2]=='1')
	$tingkat='I';
	else if ($hasilmhs[2]=='2')
	$tingkat='II';
	else
	$tingkat='III';
if ($hasilmhs[4]=='1')
	$smt='I';
	else if ($hasilmhs[4]=='2')
	$smt='II';
	else if ($hasilmhs[4]=='3')
	$smt='III';
	else if ($hasilmhs[4]=='4')
	$smt='IV';
	else if ($hasilmhs[4]=='5')
	$smt='V';
	else
	$smt='VI';
echo"<table border=0 width=700>
	<tr><td align=center><h2><u>KARTU RENCANA STUDI</u></h2></td></tr></table>";
echo"<table border=0>";
echo"<tr><td>NIM</td>  <td width=400>: $nim</td> <td>Tingkat</> <td>: $tingkat</td></tr>";
echo"<tr><td>Nama</td> <td width=400>: $hasilmhs[1]</td> <td>Angkatan</> <td>: $hasilmhs[14]</td></tr>";
echo"<tr><td>Semester</td> <td width=400>: $smt</td> <td>T.A</td> <td>: $ta<br></td</tr></table>";
}
}
?>
<table border="1" width="700">
<tr><th>No.</th>
 <th>Kode</th>
 <th>Mata Kuliah</th>
 <th>SKS</th>
</tr>
<?php
include"connect.php";
$sqlkrs = mysqli_query($koneksi,"SELECT * FROM krs, mtk WHERE nim='$nim'
 AND krs.kd_mtk = mtk.kd_mtk
 AND krs.semester='$semester' AND krs.ta='$ta' order by mtk.kd_mtk ASC");

$i = 1;
$jumsks = 0;
while($datakrs = mysqli_fetch_array($sqlkrs)){
 echo "<tr><td align=center>$i</td>";
 echo "<td align=center>$datakrs[kd_mtk]</td>";
 echo "<td>$datakrs[nm_mtk]</td>";
 echo "<td align=center>$datakrs[jsks]</td>";
 $jumsks = $jumsks + $datakrs['jsks'];
 $i++;
}
echo "<tr><td colspan=3>Jumlah SKS semester</td><td align=center>$jumsks</td></tr>";
//
$sql_krs = mysqli_query($koneksi,"SELECT * FROM krs, mtk WHERE nim='$nim'
 AND krs.kd_mtk = mtk.kd_mtk AND krs.semester!='$semester' AND krs.nilai != 0");
$jsks = 0;
$j = 1;
while($dkrs = mysqli_fetch_array($sql_krs)){
 $jsks = $jsks + $dkrs['jsks'];
 $j++;
}
echo "<tr><td colspan=3>Total SKS sudah di tempuh</td><td align=center>$jsks</td></tr>";

?>
</table>
<p>&nbsp;</p>
<table border="0" width="700">
<tr>
<td>Catatan Pembimbing :
<p>.................................................................</p>
<p>.................................................................</p>
<p>.................................................................</p>
</td>
<td></td>
<?
$namabulan = array("","Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","Nopember","Desember");
$tgl= date("j");
$bln= $namabulan[date("n")];
$thn= date("Y");
?>
<td align="center"><p>Cikarang ,<? echo " 12 Februari 2023";//echo " $tgl $bln $thn"; ?> <br>
  STIKes Bhakti Husada Cikarang <br>
  Ketua, </p>
  <p>&nbsp;</p>
  <p><br>
      <u><? echo " $pset[1]"; ?></u>
      <br>
    NIK.<? echo " $pset[0]"; ?></p></td></tr>
</table>

