Could someone help my with an issue I have? I have made an select list with different options, based on the option the user did choice I want to run a certain function so i can later show the data which i have already saved in my database.
However how do I do this? right now I have been working with: if(!empty($_POST["option1"]))
to check which option is selected but the code will never get inside those if statements. the code stops after: if(!empty($_POST["confirmOption"]))
<form method="post" action="index.php">
<select id="list" name="list">
<option selected><--select option--></option>
<option value="option1">test1</option>
<option value="option2">test2</option>
<option value="option3">test3</option>
<option value="option4">test4</option>
</select>
<button name="confirmOption">confirm option</button
</form>
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(!empty($_POST["confirmOption"])){
if(!empty($_POST["option1"])){
$conn = openDatabase();
$query = $conn->prepare("SELECT * FROM choices WHERE status = 'option1'");
$query->execute();
return $query->fetchAll();
}elseif(!empty($_POST["option2"])){
$conn = openDatabase();
$query = $conn->prepare("SELECT * FROM choices WHERE status = 'option2'");
$query->execute();
return $query->fetchAll();
}elseif(!empty($_POST["option3"])){
$conn = openDatabase();
$query = $conn->prepare("SELECT * FROM choices WHERE status = 'option3'");
$query->execute();
return $query->fetchAll();
}elseif(!empty($_POST["option4"])){
$conn = openDatabase();
$query = $conn->prepare("SELECT * FROM choices WHERE status = 'option4'");
$query->execute();
return $query->fetchAll();
}
}
}