im new in prepared statements. also im not used at using checkbox with more confusing of time formats
and also i'd want to change the insert into update i dont know how to change update prepared statement based on my query. please help
the query is correct, the data is inserted but the time has error. it only insert this 00:00:01 i dont know why
What I have tried:
CREATE TABLE `monday` (
`id` int(11) NOT NULL,
`username` varchar(255) NOT NULL,
`first` time NOT NULL,
`second` time NOT NULL,
`third` time NOT NULL,
`fourth` time NOT NULL,
`fifth` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
$now = new DateTime();
$stmt = $DBcon->prepare("INSERT INTO monday(username,first,second,third,fourth,fifth)
VALUES (?, ?, ?, ?, ?, ?)");
$username = $userRow['username'];
$first = $now -> format("H:i") > "07:00";
$second = $now -> format("H:i") > "10:00";
$third = $now -> format("H:i") > "13:00";
$fourh = $now -> format("H:i") > "16:00";
$fifth = $now -> format("H:i") > "19:00";
$stmt->bind_param("ssssss",$username, $first, $second, $third,
$fourh, $fifth);
$status = $stmt->execute();
if(!$status) {
echo $stmt->error;
exit; }
echo "<br>success";
}
<form method="post">
<td><input type="checkbox" name="time[]" >7:00 am
<td><input type="checkbox" name="time[]" >10:00 am
<td><input type="checkbox" name="time[]" >1:00 pm
<td><input type="checkbox" name="time[]" >4:00 pm
<td><input type="checkbox" name="time[]" >7:00 pm
<br><input type="submit" name="submit"></td>
</form>