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