$strSQL = "SELECT * FROM animal WHERE Enable='T' AND (CreatedBy BETWEEN '".$_GET['dateinput']."' AND '".$_GET['dateinput2']."') ";
if($_GET["dateinput"]!= "")
{
$strSQL .= " and (CreatedBy LIKE '%".$_GET["dateinput"]."%') ";
}
if($_GET["dateinput2"]!= "")
{
$strSQL .= " and (CreatedBy LIKE '%".$_GET["dateinput2"]."%') ";
}
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]") ;
echo strSQL;
SELECT * FROM animal WHERE Enable='T' AND (CreatedBy BETWEEN '' AND '') and ... ลอง echo strSQL มาแล้วครับ ค่า GET ไม่ส่งเข้าไป ช่วยหน่อยนะครับ = =+
echo strSQL;
SELECT * FROM animal WHERE Enable='T' and (CreatedBy BETWEEN '07-07-2011' and '07-07-2011') and (IsActive LIKE '%2%') and (CreatedBy LIKE '%07-07-2011%') and (CreatedBy LIKE '%07-07-2011%')
แต่สิ่งที่ค้นหามันไม่ขึ้นมาอะครับ
$strSQL = "SELECT * FROM animal WHERE Enable='T' and (CreatedBy BETWEEN '".$_GET['dateInput']."' and '".$_GET['dateInput2']."') ";
if($_GET["txtKeyword"]!= "")
{
$strSQL .= " and (ThaiName LIKE '%".$_GET["txtKeyword"]."%' or EngName LIKE '%".$_GET["txtKeyword"]."%') ";
}
if($_GET["IsActive"]!= "")
{
$strSQL .= " and (IsActive LIKE '%".$_GET["IsActive"]."%') ";
}
if($_GET["txtKeyword2"]!= "")
{
$strSQL .= " and (Created LIKE '%".$_GET["txtKeyword2"]."%') ";
}
if($_GET["txtKeyword3"]!= "")
{
$strSQL .= " and (Updated LIKE '%".$_GET["txtKeyword3"]."%') ";
}
if($_GET["dateInput"]!= "")
{
$strSQL .= " and (CreatedBy LIKE '%".$_GET["dateInput"]."%') ";
}
if($_GET["dateInput2"]!= "")
{
$strSQL .= " and (CreatedBy LIKE '%".$_GET["dateInput2"]."%') ";
}
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]") ;
เก็บเป็น date แล้วครับ แต่ error
Warning: mssql_query() [function.mssql-query]: message: Conversion failed when converting date and/or time from character string. (severity 16) in C:\AppServ\www\1799\animal_show.php on line 122
Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\1799\animal_show.php on line 122
Error Query [SELECT * FROM animal WHERE Enable='T' AND (CreatedBy BETWEEN '04-07-2011' AND '20-07-2011') and (IsActive LIKE '%1%') ]