<?php
$conn = mysqli_connect('localhost', 'root', '', 'dam');

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$res = mysqli_query($conn, 'SELECT id_pengguna FROM pengguna ORDER BY id_pengguna ASC');
$index = 0;
while($row = mysqli_fetch_assoc($res)) {
    $id = $row['id_pengguna'];
    // We want the dates to progress but maybe repeat if many users
    // If we want id 1 to be 2026-05-01, id 2 to be 2026-05-02
    // We can do ($index % 31) + 1
    // Let's make it increment every 2 users just to mix it up
    $day = (floor($index / 2) % 31) + 1;
    $date = sprintf("2026-05-%02d", $day);
    
    $q = "UPDATE kuesioner SET tanggal = '$date' WHERE id_pengguna = '$id'";
    mysqli_query($conn, $q);
    $index++;
}
echo "Dates updated successfully.";
?>
