I'm using ajax to take user input in a dropdown menu (so the input would be the chosen alternative) and show some information after a button is clicked. It works, but I want to use a switch case statement in the controller, which is not working.
I have this piece of code to populate the dropdown menu:
<form method="post" action="controleur.php">
<select name="liste_formations" id="liste_formations" class="form-control">
<option value="">Choisissez une formation</option>
<?php
while($row = mysqli_fetch_array($result))
{
echo '<option value="'.$row["idActivite"].'">'.$row["nom"].'</option>';
}
?>
</select>
</div>
<div class="col-md-4">
<input type="submit" name="action" class="btn" id="search" value="Voir informations" />
</form>
And when the user clicks the send button it goes to controller.php where I have:
case "Voir informations":
$idActivite = $_POST['liste_formations'];
$query = "SELECT * FROM formation WHERE idActivite = '$idActivite'";
$result = mysqli_query($db, $query);
while($row = mysqli_fetch_array($result))
{
$data["nombreMaxPart"] = $row["nombreMaxPart"];
$data["idFormateur"] = $row["idFormateur"];
$data["prix"] = $row["prix"];
$data["description"] = $row["description"];
}
echo json_encode($data);
break;
When I try to do that I get the information I want, but in a blank page with the information vector. I actually want to show it in a table.