如何从bootstrap datepicker获取值并将其传递给比较数据存储数据库

时间:2017-01-20 22:29:08

标签: php jquery datepicker

我想从datepicker获取值(仅在更改时不使用任何按钮),并将此日期与存储的数据库进行比较。我的项目是订单,每个订单都有一个日期,所以我想根据日期查看旧订单或新订单。此外,在打开网站时,它应显示当前日期(今天)及其订单。这是我的代码:

<input class="datepicker" name="datepicker"  id="datepicker" />

<script> //date picker js

$(function() {               
  $("#datepicker" ).datepicker({

    dateFormat : 'dd-mm-yy',

  });
});
</script>


$q_customer = $conn->query("SELECT * from orders inner JOIN 
        customer_order on customer_order.order_no 
        =orders.order_no inner join driver_order  on 
        driver_order.order_no=orders.order_no LEFT JOIN 
        customer on customer.phone=customer_order.phone 
        order by k_time" ) or die(mysqli_error());

$k_time = '';

while($f_customer = $q_customer->fetch_array()){?>

<tr>
<?php

if($k_time == '' || $k_time != $f_customer['k_time']){
  $k_time = $f_customer['k_time'];

  echo "<td>".$f_customer['k_time']."</td>";

} else{
  echo "<td>&nbsp;</td>";
}
?>

<td><?php echo $f_customer['order_no']?></td>
<td><?php echo $f_customer['first_name']?></td>
<td><?php echo $f_customer['last_name']?></td>
<td><?php echo $f_customer['address']?></td>
<td><?php echo $f_customer['driver_no']?></td>
<td><?php echo $f_customer['d_time']?></td>
<td><?php echo $f_customer['no_ofppl']?></td>

1 个答案:

答案 0 :(得分:0)

$('#datepicker').datepicker('getDate');

您也可以将其设置为变量,或者如果您想通过选择日期来获取日期,请尝试此操作。

$('#datepicker').on('changeDate', function(e) {
  var date = e.date;
});

虽然你需要改变日期的格式。