prepare($query); $stmt->bind_param("i", $batch_id); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($id); $stmt->fetch(); // Return response if the batch exists echo json_encode(['exists' => true, 'id' => $id]); } else { // Return response if the batch doesn't exist echo json_encode(['exists' => false]); } $stmt->close(); } ?>