我想基于来自& amp;来过滤表行。至今。前端正在运作:
但是onclick"搜索"按钮,页面将刷新,但它不会过滤行....
HTML
<form name="frmSearch" method="post" action="">
<input id="post_at" name="search[post_at]" value="<?php echo $post_at; ?>" />
<input id="post_at_to_date" name="search[post_at_to_date]" value="<?php echo $post_at_to_date; ?>" />
<input type="submit" name="go" value="Search" >
<table id="content-table">
<tr>
<th>order id</th>
<th>date</th>
</tr>
<?php
if(!empty($orderrecords))
{
foreach($orderrecords as $k=>$v)
{
?>
<tr>
<td><?php echo $orderrecords[$k]["order_id"]; ?></td>
<td><?php echo $orderrecords[$k]["sent_date"]; ?></td>
</tr>
</table>
<?php
}
}
?>
</form>
PHP
$conn = mysqli_connect("localhost", "root", "", "");
$post_at = "";
$post_at_to_date = "";
$queryCondition = "";
if(!empty($_POST["search"]["post_at"])) {
$post_at = $_POST["search"]["post_at"];
list($fid,$fim,$fiy) = explode("-",$post_at);
$post_at_todate = date('Y-m-d');
if(!empty($_POST["search"]["post_at_to_date"])) {
$post_at_to_date = $_POST["search"]["post_at_to_date"];
list($tid,$tim,$tiy) = explode("-",$_POST["search"]["post_at_to_date"]);
$post_at_todate = "$tiy-$tim-$tid";
}
$queryCondition .= "WHERE sent_date BETWEEN '$fiy-$fim-$fid' AND '" . $post_at_todate . "'";
}
$sql4 = "SELECT * from do_order " . $queryCondition . " ORDER BY sent_date desc";
$result = mysqli_query($conn,$sql4);
脚本
$.datepicker.setDefaults({
showOn: "button",
buttonImage: "datepicker.png",
buttonText: "Date Picker",
buttonImageOnly: true,
dateFormat: 'yy-mm-dd'
});
$(function() {
$("#post_at").datepicker();
$("#post_at_to_date").datepicker();
});
var_dump code :
var_dump($sql4);
var_dump($post_at);
var_dump($post_at_to_date);
var转储结果:
string(100) "SELECT * from do_order WHERE sent_date BETWEEN '2018-03-01' AND '2018-03-27' ORDER BY sent_date desc"
string(10) "01-03-2018"
string(10) "27-03-2018"
我正在使用mysqli,如果您需要任何其他信息,请告诉我....
请帮我找到解决方案,提前致谢....