php依據輸入開始時間 結束時間搜尋訂單資料

來源:互聯網
上載者:User
php根據輸入開始時間 結束時間搜尋訂單資料
 





資料庫表名是dede_shops_orders,時間欄位是stime(int類型)已經轉化為時間資料顯示了:;控制項已做好,想根據倆個input的時間資料進行搜尋,PHP頁面如何處理啊,求大神指點!
------解決思路----------------------
select的時候where區間查詢,> 和<
------解決思路----------------------
shops_operations.php頁面根據傳過來的 起始時間 $startTime 和結束時間 $endTime寫出sql
select * from dede_shops_orders where `stime` between $startTime and $endTime.
要先把 起始時間和結束時間也轉化成整型
------解決思路----------------------
引用:
Quote: 引用:

Quote: 引用:

shops_operations.php頁面根據傳過來的 起始時間 $startTime 和結束時間 $endTime寫出sql
select * from dede_shops_orders where `stime` between $startTime and $endTime.
要先把 起始時間和結束時間也轉化成整型

//訂單時間查詢
$t1=$_POST['starttime'];//開始時間
$t2=$_POST['endtime'];//結束時間
//var_dump($t1);
//die;
$sql="select * from dede_shops_orders where `stime` between $startTime and $endTime.";
$result=mysql_query($sql);
while($row=mysql_fetch_row($result)){
echo $row[0].' '.$row[1].'
';
}
現在改成這樣了 這個stime資料庫是140551515 是用函數做過處理的。。。接下來要怎麼改啊
$sql="select * from dede_shops_orders where `stime` between $t1and $t2.

這個已經是按起始時間和結束時間搜尋出結果了啊
------解決思路----------------------
你列印下 $t1 $t2 還有資料庫裡面存的stime欄位都是什麼樣的?
------解決思路----------------------
。。。 哦 看出問題了 你的 form表單是get方式提交。 你擷取值的時候用的是$_POST ,肯定擷取不到值啊
------解決思路----------------------
method="get" 改為 method="post"
------解決思路----------------------
比例的時候要用一樣的格式。既然你資料庫裡時間存的是int,那時間條件也轉換成int去比較。
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.