<?php
include '../db.php'; // Include your database connection

if(isset($_POST['list']) && isset($_POST['college_id'])){
    $list = $_POST['list']; // Selected values (comma-separated)
    $college_id = mysqli_real_escape_string($con, $_POST['college_id']); // Prevent SQL injection

    if(empty($list)){
        $query = "UPDATE data SET data_seo_title = NULL WHERE data_catagory = 'cEntrance' AND data_up_for = '$college_id'";
    } else {
        $list = mysqli_real_escape_string($con, $list); // Prevent SQL injection
        $query = "UPDATE data SET data_seo_title = '$list' WHERE data_catagory = 'cEntrance' AND data_up_for = '$college_id'";
    }

    if(mysqli_query($con, $query)){
        echo "Success";
    } else {
        echo "SQL Error: " . mysqli_error($con); // Print SQL error if any
    }
}
?>