Php准备好的声明复选框插入 [英] Php prepared statement check box insert

查看:56
本文介绍了Php准备好的声明复选框插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我准备好的陈述中的新内容。我也不习惯使用复选框,时间格式更混乱





我也想要将插入更改为更新我不知道如何根据我的查询更改更新准备语句。请帮助



查询正确,数据插入但时间有误。它只插入00:00:01我不知道为什么



我尝试了什么:



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>

推荐答案

now = new DateTime();

now = new DateTime();


stmt =
stmt =


DBcon-> prepare( INSERT INTO星期一(用户名,第一,第二,第三,第四,第五)
VALUES(? ,?,?,?,?,?)
);


DBcon->prepare("INSERT INTO monday(username,first,second,third,fourth,fifth) VALUES (?, ?, ?, ?, ?, ?)");


这篇关于Php准备好的声明复选框插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆