<?php
$db = mysqli_connect('127.0.0.1', 'root', '', 'siakad');

$res = mysqli_query($db, "SELECT id, nama_prodi FROM program_studi");
while($row = mysqli_fetch_assoc($res)) {
    $id = (int)$row['id'];
    $nama = mysqli_real_escape_string($db, $row['nama_prodi']);
    
    $update = "UPDATE penugasan_dosen SET id_program_studi = $id WHERE nama_program_studi LIKE '%$nama%'";
    if(mysqli_query($db, $update)) {
        echo "Updated $nama: " . mysqli_affected_rows($db) . " rows\n";
    }
}
echo "Done.\n";
