dora1989
2017-01-20 22:29
浏览 110

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

I want to get value from datepicker (only on change without using any button), and compare this date with stored database. My project is for orders and every order has a date, so I want to view old or new orders depending on their dates. Also when opening the website, it should display the current date (today) with its orders. Here's my code:

<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>

图片转代码服务由CSDN问答提供 功能建议

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

 &lt; input class =“datepicker”name =“datepicker”id =“datepicker”/&gt; 
 
&lt; script&gt;  //日期选择器js 
 
 $(function(){
 $(“#datepicker”)。datepicker({
 
 dateFormat:'dd-mm-yy',
 
}); \  n}); 
&lt; / script&gt; 
 
 
 $ q_customer = $ conn-&gt; query(“SELECT *来自订单内部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 in customer.phone = customer_order.phone 
 order by k_time“)或die(mysqli_error()); 
 
 $ k_time =''; 
 \  nwhile($ f_customer = $ q_customer-&gt; fetch_array()){?&gt; 
 
&lt; tr&gt; 
&lt;?php 
 
if($ k_time ==''|| $ k_time!= $ f_customer [  'k_time']){
 $ k_time = $ f_customer ['k_time']; 
 
 echo“&lt; td&gt;”。$ f_customer ['k_time']。“&lt; / td&gt;”; 
 \  n} else {
 echo“&lt; td&gt;&amp; nbsp;&lt; / td&gt;”; 
} 
?&gt; 
 
&lt; td&gt;&lt;?php echo $ f_customer ['order_no']  ?&gt;&lt; / td&gt; 
&lt; td&gt;&lt;?php echo $ f_customer ['first_name']?&gt;&lt; / td&gt; 
&lt; td&gt;&lt;?php echo $ f_customer ['last_name']  ?&GT;&升 t; / td&gt; 
&lt; td&gt;&lt;?php echo $ f_customer ['address']?&gt;&lt; / td&gt; 
&lt; td&gt;&lt;?php echo $ f_customer ['driver_no']?&gt;  &lt; / td&gt; 
&lt; td&gt;&lt;?php echo $ f_customer ['d_time']?&gt;&lt; / td&gt; 
&lt; td&gt;&lt;?php echo $ f_customer ['no_ofppl']?&gt;  &lt; / td&gt; 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doutang1946 2017-01-21 06:53
    已采纳

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

    You can also set this as a variable or if you want to get the date by selecting the day then try this.

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

    Althought you need to change the format of the date.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题