使用mysql_query将时间和日期插入数据库

时间:2016-11-30 05:02:40

标签: javascript php mysql sql database

 <form action="actionMAppointment.php?stu_id=<?php echo $row_RecEdit['stu_id'] ?>" method="post">
        Time:
        <input type = "time" name="appointmentTime" id = "appointmentTime" />
        Date:
        <input type = "text" name="appointmentDate" id = "appointmentDate" />
        <input type = "submit" value="Make Appointment"/>
 </form>

actionMAppointment.php

$temp_id = $_GET['stu_id'];
$app_time    = $_POST['appointmentTime'];
$app_date    = $_POST['appointmentDate'];
$the_time = date('h:i A', strtotime($app_time));
mysql_query("UPDATE tbl_studentdetail SET stu_appointment = 1, appointment_time = $the_time, appointment_date = $app_date WHERE stu_id = $temp_id"); 
header("Location:appointment.php");
?>

Javascript for date

<style type="text/css">@import "js_pickdate/jquery.datepick.css";</style> 
<script type="text/javascript" src="js_pickdate/jquery.datepick.js">      </script>
<script type="text/javascript">
$(document).ready(function(){
    $('#appointmentDate').datepick({dateFormat: 'yy-mm-dd'});
});

由于某种原因,它根本不更新数据库。任何人都可以帮忙谢谢!

1 个答案:

答案 0 :(得分:0)

可能你应该改变

$('#appointmentDate').datepick({dateFormat: 'yy-mm-dd'});

 $('#appointmentDate').datepick({dateFormat: 'yyyy-mm-dd'});