prepare("SELECT * FROM qudao WHERE id = ?"); $stmt->bind_param("i", $id); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $stmt = $conn->prepare("UPDATE qudao SET ch_name = ? WHERE id = ?"); $stmt->bind_param("si", $ch_name, $id); $stmt->execute(); } $page = $_GET['Page'] ?? ''; $keys = urlencode($_GET['Keys'] ?? ''); $ord = urlencode($_GET['Ord'] ?? ''); header("Location: ?keys=$keys&Ord=$ord&Page=$page"); exit; } else { $stmt = $conn->prepare("INSERT INTO qudao (ch_name) VALUES (?)"); $stmt->bind_param("s", $ch_name); $stmt->execute(); header("Location: ?"); exit; } } if ($act == 'postchk') { $keys = urlencode($_GET['Keys'] ?? ''); $ord = urlencode($_GET['Ord'] ?? ''); $page = $_GET['Page'] ?? ''; if (isset($_POST['chkbox']) && is_array($_POST['chkbox'])) { $ids = array_map('intval', $_POST['chkbox']); $idList = implode(',', $ids); if (!empty($idList)) { $stmt = $conn->prepare("DELETE FROM qudao WHERE id IN ($idList)"); $stmt->execute(); } } header("Location: ?Keys=$keys&Ord=$ord&Page=$page"); exit; } // Now we can start HTML output ?>