<?php
require_once('../koneksi.php');

if(isset($_POST['simpan'])) {
    foreach($_POST['id_siswa'] as $id_s) {
        $tp1 = $_POST['tp1'][$id_s];
        $tp2 = $_POST['tp2'][$id_s];
        $sas = $_POST['sas'][$id_s];
        
        // Simpan ke database (sesuaikan dengan nama tabel nilai Anda)
        mysqli_query($koneksi, "INSERT INTO nilai (id_siswa, tp1, tp2, sas) VALUES ('$id_s', '$tp1', '$tp2', '$sas')");
    }
    echo "<script>alert('Nilai berhasil disimpan!'); window.location='dashboard.php';</script>";
}
?>