I've been having some problems with a bit of PHP running when a form is submitted. I'm trying to have a variable be determined by which submit button is being pressed and grabbing the $_POST['name'] to carry out some SQL select. There are currently two submit buttons in my form, reading YES and NO.
The problem I'm having is that I keep getting the same answer from my query, but when I test in my database it works just fine. It seems to be something in my if // else statement.
if($_POST['answer1']){
$chosenAnswer = ('1');
}
else if ($_POST['answer2']){
$chosenAnswer = ('2');
}
$query = "SELECT questionFlow.NxtQ FROM ";
$query .= "questionFlow WHERE area = '{$_SESSION['probArea']}' ";
$query .= "AND ANSid = '{$chosenAnswer}' AND Qid = '{$_SESSION['x']}'";
$result = mysqli_query($connection, $query);
while ($row = mysqli_fetch_assoc($result)) {
print_r($row["NxtQ"]);
}
Aucun commentaire:
Enregistrer un commentaire