0
我有這個表我的SQL查詢搜索框
date | Expedition | Destination
________________________________________
12/05/2012 | UPS | New York
12/05/2012 | DHL | New York
13/06/2012 | ATLAS | Atlanta
14/06/2012 | JNE | Chicago
我想創建的搜索結果,這我的代碼
<form method="post" action="sales.php?ID=expLocal">
Pencarian <input type="text" name="KUNCI" width="300"/><input type="submit" name="CARI" value="CARI" />
</form>
<?php
if (empty($_POST[CARI]))
{
$sql = "SELECT * FROM tb_exp_local";//this query for open all the data
}
else if (isset($_POST[KUNCI]))
{
$kunci=$_POST[KUNCI];
$sql="SELECT * FROM tb_exp_local WHERE MATCH (expedition,destination,date) AGAINST ('+$kunci' IN BOOLEAN MODE)"; // this is query for serching the data
}
?>
查詢運行良好,但如果搜索框中填寫日期查詢不運行。誰能告訴我如何解決這個問題?(列日期的數據類型是varchar)
爲什麼不使用的日期列日期型數據? – 2012-07-26 07:36:32
你如何防止SQL注入? – Jocelyn 2012-07-26 07:50:32
@IbrahimAzharArmar我使用varchar來準備特殊情況。 – MudMan23 2012-07-26 07:55:07