Click here to Skip to main content
15,887,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

PHP
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"; 
}



HTML
		<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>
Posted
Updated 22-Feb-17 18:31pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900