Postingan lainnya
Error array to string conversion
if ($_SERVER["REQUEST_METHOD"] == "POST" AND isset($_POST["save"])) {
$validasi = false; $err = false;
if ($update) {
$sql = "UPDATE nilai SET kd_kriteria='$_POST[kd_kriteria]', nim='$_POST[nim]', nilai='$_POST[nilai]' WHERE kd_nilai='$_GET[key]'";
} else {
$query = "INSERT INTO nilai VALUES ";
foreach ($_POST["nilai"] as $kd_kriteria => $nilai) {
$query .= "(NULL, '$_POST[kd_beasiswa]', '$kd_kriteria', '$_POST[nim]', '$nilai'),";
}
$sql = rtrim($query, ',');
$validasi = true;
}
if ($validasi) {
foreach ($_POST["nilai"] as $kd_kriteria => $nilai) {
$q = $connection->query("SELECT kd_nilai FROM nilai WHERE kd_beasiswa=$_POST[kd_beasiswa] AND kd_kriteria=$kd_kriteria AND nim=$_POST[nim] AND nilai LIKE '%$nilai%'");
if ($q->num_rows) {
echo alert("Nilai untuk ".$_POST["nim"]." sudah ada!", "?page=nilai");
$err = true;
}
}
}
if (!$err AND $connection->query($sql)) {
echo alert("Berhasil!", "?page=nilai");
} else {
echo alert("Gagal!", "?page=nilai");
}
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban