I have multiple checkboxes where the user should check the series he watches. In my database i want to update the column "watch" with the value "yes" in every series he checked (i have already created a column with all the series in it).
The HTML code:
<p>Please check the series you watch:</p>
<form action="2.php" method="post">
Game Of Thrones <input type="checkbox" value="Game Of Thrones" name="series"/><br>
The Big Bang Theory <input type="checkbox" value="The Big Bang Theory" name="series"/><br>
Arrow <input type="checkbox" value="Arrow" name="series"/><br>
<input type="submit" value="Submit">
</form>
The send.php:
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$series = $_POST['series'];
$sql = "UPDATE data SET watch='yes' WHERE series='$series'";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
It works as long as the user check only one series, but when he check two or more it updates only one of the series he checked.
Help?