如何更改datepicker取决于插入MySQLi查询和PHP

时间:2017-01-27 12:17:09

标签: php jquery datepicker

我需要知道如何做到这一点:

  • 在页面加载(打开站点)上显示具有date =当前日期(datepicker)
  • 的数据
  • 如果我更改了datepicker,则表格显示在datepicker中具有相同日期的数据。
  • 当我添加上一个日期的新记录时,表格必须在添加完成后仅显示此日期的数据。
  • 前两点工作正常,但我怎么能做最后一点? 我使用3页:index.php(仅限日期选择器),check_data.php(显示表取决于index.php的datepicker更改) 和save_customer_query.php,它将新记录添加到数据库中。
索引页面中的

代码:       

<script>
$('#datepicker').change(function () {    

$.post('check_data.php', {    
    dtpickerdate : $(this).val()
}, function (response) {    

    $('table').html(response);
  });
 });

 $("#datepicker").datepicker({dateFormat: "mm-dd-yy",}).datepicker("setDate", new Date()).change();
</script>

插入查询

$conn->query("INSERT INTO `orders` VALUES('$order_no','$address','$no_ofppl','$d_time','$k_time','$date',now(),'$done','$mile')") or die('Error: ' . mysqli_error($conn));          
    echo '
        <script type = "text/javascript">
            alert("Saved Record");
            window.location = "index.php";
            </script>
    ';       }
 }else
  {
echo 'Result Error';
   }  

Check_data.php

        <thead class = "alert-info">
 <tr>
                <th>Kitchen Time</th>

                <th>Order#</th>

                <th>First Name</th>
                <th>Last Name</th>
                <th>Address</th>
                <th>Driver#</th>
                <th>Delivery Time</th>
                <th># of People</th>
                <th>Miles</th>
            </tr> </thead><tbody>
  <?php
$dtpickerdate = isset($_POST['dtpickerdate']) ? $_POST['dtpickerdate'] : NULL;

 $q_customer = $conn->query
                             ("SELECT * from orders inner JOIN customer_order on customer_order.order_no =orders.order_no and orders.date like'$dtpickerdate' 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,time desc" )
 or die(mysqli_error());

 $k_time = '';
 while($f_customer = $q_customer->fetch_array()){
 $s=mysqli_num_rows($q_customer);
 ?>
  <tr>
 <?php   

    if($k_time == '' || $k_time != $f_customer['k_time']){
     $k_time = $f_customer['k_time'];
     echo '<td align="center" > <span style=" font-weight:bold;">' 
     .$f_customer['k_time']. '</td>';
      } else{
      echo "<td td style=' border: none;'>&nbsp;</td>";
      }
       echo "<td style='background-color: #5f5d5d; ' align='center'  span style='font-weight:bold;'> <a   href = '#' style='color:#ececec;font-weight:bold;' data-toggle = 'modal' data-target = '#action'>".$f_customer['order_no']."</a></td>";

   echo    "<td style='background-color: #5f5d5d;color:#ececec;'>" .$f_customer['first_name']."</td>"; 
  echo "<td style='background-color: #5f5d5d;color:#ececec;'>". $f_customer['last_name']."</td>";
   echo "<td style='background-color: #5f5d5d;color:#ececec;'>". $f_customer['address']."</td>";
   echo "<td style='background-color: #5f5d5d;color:#ececec;'>". $f_customer['driver_no']."</td>";
   echo "<td style='background-color: #5f5d5d;color:#ececec;'>".   $f_customer['d_time']."</td>";
   echo "<td style='background-color: #5f5d5d;color:#ececec;'>". $f_customer['no_ofppl']."</td>";
}

0 个答案:

没有答案