HTML形式的jQuery datepicker更新MySQL行 [英] jQuery datepicker in HTML form to update MySQL rows
问题描述
我已经对此主题进行了大量研究,但由于某种原因没有任何作用!
I've done heaps of research on this topic but for some reason nothings working!
我想使用datepicker小部件更新MySQL中的一行(具有日期列).出于某种原因,每当我尝试更新该行(适用于其他输入内容)时,它都会在我的MySQL表中注册???
I want to use the datepicker widget to update a row in MySQL (which has a date column). For some reason, whenever I try to update the row (which works for other input things) it says in my MySQL table 0000-00-00 ??
这是我的jQuery代码:
This is my jQuery code:
<script>
$( function() {
$( "#datepicker" ).datepicker({
dateFormat:"yy-mm-dd",
altField: "#alternate",
altFormat: "DD, d MM, yy"
});
$( "#selectable" ).selectable();
} );
</script>
还有我的HTML:
<p> Date: <input name="slot_date" id="datepicker" > <input type="text" id="alternate" size="30"></p>
我的PHP:
if( isset($_POST['btn-book']) ) {
$slot_date = date('yy-mm-dd',strtotime($_POST['slot_date']));
$slot_line=$_POST['slot_line'];
$reason=$_POST['reason'];
$id=$_POST['id'];
$sql="UPDATE appointments SET slot_date='$slot_date', slot_line='$slot_line', reason='$reason' WHERE id='$id'";
$result=mysql_query($sql);
if($result){
header ("Location: homepage_loggedin_book_success.php");
}else {
echo "ERROR";
}
}
无论如何,我已经尝试了很长时间了,但datepicker不会进入MySql表中?
Anyway, i've been trying for ages but the datepicker wont enter into my MySql table??
推荐答案
在创建记录的原始表单中,所有设置是否正确? slot_line
和reason
字段是否正确更新?如果不是,那么问题可能出在您的PHP中.您可以为上下文发布更多的PHP代码吗?
In the original form which created the record, is everything being set correctly? Are the slot_line
and reason
fields updating correctly? If they aren't the problem could be in your PHP. Could you post more of the PHP code for context?
这篇关于HTML形式的jQuery datepicker更新MySQL行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!