P粉9305342802023-07-26 09:07:18
First of all, I don't understand how to select two radio buttons at the same time, do you mean checkboxes? Regarding your question - anyway, you should execute a query, but build it based on your $_POST value
maybe like this:
// 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!'; }