Created
December 24, 2019 14:47
-
-
Save 333crist/26910a9ac4a3860c471101a9948cfc4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); //hilangkan eror | |
ini_set('max_execution_time', 0); // max execution | |
$conn = new mysqli("localhost", "root", "", "kristiandes"); //sesuaikan database | |
$n = $_POST['n']; | |
for ($i=1; $i<=$n; $i++) | |
{ | |
$id_sim = $_POST['id_sim'.$i]; | |
$nilai_ujian_sim = $_POST['nilai_ujian_sim'.$i]; | |
$query = "UPDATE simultan_data SET nilai_ujian_sim = '$nilai_ujian_sim' WHERE id_sim = '$id_sim'"; | |
mysqli_query($conn,$query); | |
} | |
?> | |
<form name="form1" method="post" action=""> | |
<!-- HEADER LAYOUT --> | |
<h1>kristiandes.com</h1> | |
<!-- END HEADER LAYOUT --> | |
<!-- HEADER TABLE --> | |
<input type="submit" value="Simpan" name="submit"/> | |
<hr> | |
<table border=1 width="30%"> | |
<tr> | |
<th>Nama</th> | |
<th>Nilai</th> | |
</tr> | |
<!-- END HEADER TABLE --> | |
<!-- BODY TABLE --> | |
<?php | |
$i = 1; | |
$ssql="SELECT * FROM simultan_data"; | |
$hasil = mysqli_query($conn,$ssql); | |
while($rowac = mysqli_fetch_array($hasil)) | |
{ | |
if(!$rowac) | |
{ | |
echo "data kosong"; | |
} | |
else { | |
//Fetch the details | |
$i++; | |
$id_sim = $rowac['id_sim']; | |
$nama_sim = $rowac['nama_sim']; | |
$nilai_ujian_sim = $rowac['nilai_ujian_sim']; | |
echo "<tr><td>$nama_sim</td>"; | |
?> | |
<td><input name="id_sim<?php echo $i; ?>" type="hidden" id="id_sim" value="<?php echo $id_sim; ?>" size="1"> | |
<input name="nilai_ujian_sim<?php echo $i; ?>" type="text" id="nilai_ujian_sim" value="<?php echo $nilai_ujian_sim; ?>" size="1"> | |
</td> | |
<?php | |
echo "</tr>"; | |
} | |
} | |
$jumMhs = $i; | |
?> | |
<input type="hidden" name="n" value="<?php echo $jumMhs ?>" /> | |
<?php | |
mysqli_close($conn); | |
?> | |
<!-- END BODY TABLE --> | |
</table> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment