<?php
$conn = new mysqli("localhost","root","","rs_lab");

$id = $_GET['id'];
$view = $_GET['view'] ?? 'active';

$res = $conn->query("SELECT status FROM institutions WHERE id=$id AND deleted_at IS NULL");
$row = $res->fetch_assoc();

if($row){
    $newStatus = ($row['status'] == 'active') ? 'inactive' : 'active';
    $conn->query("UPDATE institutions SET status='$newStatus' WHERE id=$id");
}

header("Location: admin_dashboard.php?view=".$view);
exit;