I created a quiz and I have problem with answers. When I input the answer, the answer want to insert in to id that is play the game. Instead it creates another id in the table. How can I input multiple answers in different columns but same row?
I tried like this:
if(isset($_POST['button'])) {
$box = $_POST['opt'];
$sql = "INSERT INTO gamer (jedan) VALUES ('$box')";
if(mysqli_query($connsql, $sql)) {
header('Location:qu2.php');
} else {
echo'Odgovor nije ubacen!';
}
}
You want to use update, not insert. Something like this:
UPDATE gamer
SET jedan = ?
WHERE id = ?;
Note that you should be using parameterized queries rather than munging query strings. This is especially important in your case, because the answer to a question could contain all sorts of characters that would break the SQL query.