0

我在 oscommerce 上有一个订单页面,带有一个搜索框,允许用户通过购买日期过滤结果。

这是用于显示搜索框的 html 标记,它使用 jquery datepicker 来选择日期:

<table border="0" align="right">
<tr><?php echo tep_draw_form('search_date_purchased', FILENAME_ORDERS, '', 'get'); ?>

<td class="smallText" align="right"><?php echo TEXT_ORDER_DATE;?>&nbsp;<input type="text" name="search_date_purchased" placeholder="Choose a Date" class="datepick"/></td>
</form>
</tr>
</table>

tep_draw_formis的 html 输出,<form name="search_date_purchased" action="../admin/orders.php" method="get"> 这里是运行搜索框查询的 php 端:

if (isset($HTTP_GET_VARS['search_date_purchased']) && !empty($HTTP_GET_VARS['search_date_purchased'])){




    if (strstr($HTTP_GET_VARS['search_date_purchased'],'-')){

        $search_date = explode("-", $HTTP_GET_VARS['search_date_purchased']);   

        $start_date = substr($search_date[0],6,4).'-'.substr($search_date[0],3,2).'-'.substr($search_date[0],0,2).' 17:00:00';

        $end_date = substr($search_date[1],6,4).'-'.substr($search_date[1],3,2).'-'.substr($search_date[1],0,2).' 17:00:00';    

        $search_query = "and (o.date_purchased >='".$start_date."' and o.date_purchased <='".$end_date."') ";


    }else{


    $start_date = substr($HTTP_GET_VARS['search_date_purchased'],6,4).'-'.substr($HTTP_GET_VARS['search_date_purchased'],3,2).'-'.substr($HTTP_GET_VARS['search_date_purchased'],0,2).' 17:00:00';

    $end_date = substr($HTTP_GET_VARS['search_date_purchased'],6,4).'-'.substr($HTTP_GET_VARS['search_date_purchased'],3,2).'-'.substr($HTTP_GET_VARS['search_date_purchased'],0,2).' 17:00:00';    

        $search_query = "and (o.date_purchased >='".$start_date."' and o.date_purchased <='".$end_date."') ";
    }

}else{
    $yesterday = date("Y-m-d",strtotime('-1 day')).' 17:00:00';
    $today = date("Y-m-d").' 17:00:00'; 
    $search_query = "and (o.date_purchased >='".$yesterday."' and o.date_purchased <='".$today."') ";

}

if (isset($HTTP_GET_VARS['cID'])) {


  $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.franchise_id, o.last_modified, o.date_allocated, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total'  " . $franchise_search . "order by orders_id DESC ";
} elseif (isset($HTTP_GET_VARS['status']) && is_numeric($HTTP_GET_VARS['status']) && ($HTTP_GET_VARS['status'] > 0)) {
  $status = tep_db_prepare_input($HTTP_GET_VARS['status']);
  $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.franchise_id,o.date_purchased, o.last_modified, o.currency, o.currency_value, o.date_allocated, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total'  " . $franchise_search . "order by o.orders_id DESC ";
} else {
  $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.date_purchased, o.franchise_id, o.last_modified, o.date_allocated, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total'  " . $search_query . " order by o.orders_id DESC";
}

目前它所做的只是显示输入框的值,以及在 URL 中搜索的日期,但它没有运行搜索。关于为什么以及如何解决的任何想法?

4

0 回答 0