Pertama sekali, saya tidak faham cara memilih dua butang radio pada masa yang sama, adakah anda maksudkan kotak semak? Mengenai soalan anda - bagaimanapun, anda harus melaksanakan pertanyaan tetapi membinanya berdasarkan nilai $_POST anda
mungkin seperti ini:
// make an empty array to hold all the conditions $whereValues = []; // populate the array with conditions if (in_array($_POST['searcha'], $search_a_option_list)) { $whereValues[] = "inth = '$_POST[searcha]'"; } else if ($_POST['searchb']) { $whereValues[] = "bunty LIKE '%$_POST[searchb]%'" } else if (isset($_POST['radio1'], $_POST['radio2'])) { $whereValues[] = "ref = 'In' OR ref1 = 'On'" } else if (isset($_POST['radio1'])) { $whereValues[] = "ref = 'In'" } else if (isset($_POST['radio2'])) { $whereValues[] = "ref1 = 'On'" } // if we have something then build the result string of `WHERE` conditions if ($whereValues) { $where = implode(' AND ', $whereValues); $stmt = $pdo->prepare("SELECT * FROM coun WHERE $where"); $stmt->execute(); $search_results = $stmt->fetchAll(PDO::FETCH_ASSOC); } else { $error = 'No options selected!'; }