I have problems with understanding how to update multiple SQL data with my PDO query coming from several input fields. Here is my example:
My Input field generated by PDO row:
<form action="" method="POST">
<?php
$statement = $pdo->prepare("SELECT id, question, qid FROM questions WHERE questionaire_id = :questionaire_id");
$result = $statement->execute(array(':questionaire_id' => $questionaire_id));
$count = 1;
while ($row = $statement->fetch()) {
?>
<div class="text-secondard">Frage <?= $row['qid'] ?></div>
<input type="text" name="question_id" value="<?= $row['id'] ?>" hidden>
<input type="text" class="input mb-3" name="question" value="<?= $row['question'] ?>" required>
<?php } ?>
<input type="text" name="add_question" hidden>
<button class="btn btn-primary"><i class="fas fa-plus"></i> Frage oder Anforderung erstellen</button>
</form>
My Update Query:
$question = $_POST['question'];
$id = $_POST['question_id'];
$statement = $pdo->prepare("UPDATE questions SET question = :question WHERE id = :id");
$result = $statement->execute(array(':id' => $id, ':question' => $question));