HTML形式的jQuery datepicker更新MySQL行 [英] jQuery datepicker in HTML form to update MySQL rows

查看:80
本文介绍了HTML形式的jQuery datepicker更新MySQL行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经对此主题进行了大量研究,但由于某种原因没有任何作用!

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" > &nbsp; <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_linereason字段是否正确更新?如果不是,那么问题可能出在您的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屋!

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