ผมสร้างหน้าค้นหาขึ้นมา โดย field สุดท้ายต้องการค้นเป็นข้อมูลระหว่าง between แต่ลองไส่ code ไปแล้วไม่ออกเลยครับ
พวกพี่ๆๆช่วยแนะนำหน่อยครับ
[font=Verdana]code search
Code
include("../config.inc.php") ;
$strSQL = "SELECT * FROM Member WHERE (NumberCard LIKE '%".$_GET["txtKeyword"]."%'
and IDCard LIKE '%".$_GET["txtKeyword2"]."%'
and Sex LIKE '%".$_GET["txtKeyword3"]."%'
and Age LIKE '%".$_GET["txtKeyword4"]."%'
and District LIKE '%".$_GET["txtKeyword5"]."%'
and Education LIKE '%".$_GET["txtKeyword6"]."%'
and Occuption LIKE '%".$_GET["txtKeyword7"]."%'
and Income LIKE '%".$_GET["txtKeyword8"]."%'
and Income LIKE '%".$_GET["txtKeyword9"]."%')";[/font]
Tag : PHP, MySQL, Ms SQL Server 2005, Ms SQL Server 2008, Ms SQL Server 2012
$objQuery = "SELECT * FROM Member WHERE 1";
if($_GET["txtKeyword"] != "" or $_GET["txtKeyword1"] != "" or $_GET["txtKeyword2"] != "" or $_GET["txtKeyword3"] != "" or $_GET["txtKeyword4"] != "" ){
if($_GET["txtKeyword"] != "" or $_GET["txtKeyword1"] != ""){
$objQuery .= " and (Income between '".$_GET["txtKeyword"]."' and '".$_GET["txtKeyword1"]."') ";
}
if($_GET["txtKeyword2"] != ""){
$objQuery .= " and IDCard LIKE '%".$_GET["txtKeyword2"]."%' ";
}
if($_GET["txtKeyword3"] != ""){
$objQuery .= " and Sex LIKE '%".$_GET["txtKeyword3"]."%' ";
}
if($_GET["txtKeyword4"] != ""){
$objQuery .= " and Age LIKE '%".$_GET["txtKeyword4"]."%' ";
}
}
$objQuery = mssql_query($objQuery) or die ("Error Query [".$objQuery."]");
$Num_Rows = mssql_num_rows($objQuery);
$objQuery = "SELECT * FROM Member WHERE (IDCard LIKE '%".$_GET["txtKeyword2"]."%'
and Sex LIKE '%".$_GET["txtKeyword3"]."%'
and Age LIKE '%".$_GET["txtKeyword4"]."%'
and District LIKE '%".$_GET["txtKeyword5"]."%'
and Education LIKE '%".$_GET["txtKeyword6"]."%'
and Occuption LIKE '%".$_GET["txtKeyword7"]."%'
and Income >= '$txtKeyword8' and Income <= '$txtKeyword9')";