<?php
include "../koneksi.php";
$id_situs = $_POST['id_situs'];
$draw_time = $_POST['draw_time'];
$draw_end = $_POST['draw_end'];
$identitas = $_POST['identitas'];

// Tentukan nama tabel berdasarkan id_situs
switch ($identitas) {
    case 1:
        $table_name = 'atur_talaga';
        break;
    case 2:
        $table_name = 'atur_day';
        break;
    case 3:
        $table_name = 'atur_evening';
        break;
    case 4:
        $table_name = 'atur_bogor';
        break;
    default:
        echo "id_situs tidak valid.";
        exit;
}

// Lakukan query update
$query = "UPDATE $table_name SET draw_time = '$draw_time', draw_end = '$draw_end' WHERE id_situs = '$id_situs'";
$proses = mysqli_query($koneksi, $query);

if ($proses) {
    header("location:situs.php?alert=berhasil");
} else {
    echo "Proses Gagal<br>Error : " . $proses . "<br>" . mysqli_error($koneksi);
}
?>