gpt4 book ai didi

php - 将 html 日期和时间转换为我的数据库日期时间列

转载 作者:行者123 更新时间:2023-11-29 18:37:40 25 4
gpt4 key购买 nike

这些是我的 html 输入

<input id="6" type="date" name="start_date">
<input id="7" type="time" name="start_time"><br>
<input id="8" type="date" name="end_date">
<input id="9" type="time" name="end_time"><br>

然后我使用 post 方法像这样声明它们

$start_date = (string) $_POST['start_date'];
$start_time = (string) $_POST['start_time'];
$end_date = (string) $_POST['end_date'];
$end_time = (string) $_POST['end_time'];

最后像这样执行查询

$dateTimeStart="$start_date.' '.$start_time";
$dateTimeEnd="$end_date.' '.$end_time";
$dateTimeStart = date("Y-m-d H:i:s",strtotime($dateTimeStart));
$dateTimeEnd = date("Y-m-d H:i:s",strtotime($dateTimeEndime));
$sql="INSERT INTO appointment (prof_id, student_id, app_start, app_end) VALUES ('$prof_id', '(SELECT user_id FROM user WHERE firstname='$stud_first' AND lastname='$stud_last')', '$dateTimeStart', '$dateTimeEnd');";
mysqli_query($conn, $sql);

但是好像出了什么问题..你能帮我吗?

最佳答案

尝试删除子选择周围的引号:

       $sql="INSERT INTO appointment (prof_id, student_id, app_start, app_end) VALUES ('$prof_id', (SELECT user_id FROM user WHERE firstname='$stud_first' AND lastname='$stud_last'), '$dateTimeStart', '$dateTimeEnd');";

关于php - 将 html 日期和时间转换为我的数据库日期时间列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45153768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com