This question already has an answer here:
$query = "SELECT question, id FROM qs ORDER BY id DESC";
$results = mysqli_query($db, $query);
while ($row = mysqli_fetch_row($results)) {
echo "<div class='question'>".$row[0]." / ".$row[1]."</div><form method='POST' action='index.php'><input type='text' name='answer-box' placeholder='Answers'><input name='replyb' value='Reply' type='submit'></form><br><br>";
}
?>
$answer = @$_POST['answer-box'];
$button = @$_POST['replyb'];
if (isset($button)) {
$sql_answer = "INSERT INTO `answers` (`answer`,`id`) VALUES ('$answer', '$row[1]')";
$result_answer = mysqli_query($db, $sql_answer);
$row_answer = mysqli_fetch_row($result_answer);
} else {
}
?>
Aucun commentaire:
Enregistrer un commentaire