|
|
|
php + oracle ต้องการค้นหาจากหลายฟิวพร้อมกัน มี txtbox ต้องการค้นหาข้อมูลตั้งแต่ฟิวเดียวไปจนหลายฟิวจะทำไงคับ(ใน Oracle) |
|
|
|
|
|
|
|
ลองไปประยุกต์ดูครับ
Code (PHP)
$strSQL = "SELECT * FROM tblAA
$strSQL.="WHERE id <>'' ";
if($description!=""){
$strSQL=$strSQL." AND description = '$description' ";
}
if($itemno!=""){
$strSQL=$strSQL." AND itemno = '$itemno' ";
}
|
|
|
|
|
Date :
2010-03-19 10:22:40 |
By :
onizike |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ผมใช่แบบนี้คับ
Code (PHP)
$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =192.9.150.7)(PORT = 1521)))(CONNECT_DATA=(SID=vis)))";
if($_POST["transaction_date"] != "")
{
$c1 = OCILogon("apps","apps",$db);
$strSQL = "SELECT * From pt_mercury_material_trans where (transaction_date LIKE '%".$_POST["transaction_date"]."%') order by transaction_date , transaction_id";
$objParse = OCIParse($c1, $strSQL);
?>
.
.
.
.
.
<?
{
?>
if($_POST["item_number"] != "")
{
$c1 = OCILogon("apps","apps",$db);
$strSQL = "SELECT * From pt_mercury_material_trans where (item_number LIKE '%".$_POST["item_number"]."%') order by transaction_date , transaction_id";
$objParse = OCIParse($c1, $strSQL);
?>
.
.
.
.
.
<?
{
?>
ไปจนถึง
if($_POST["transaction_date"] != "" & $_POST["item_number"] != "" & $_POST["item_description"] != "" & $_POST["transaction_type_name"] != "" & $_POST["subinventory_code"] != "" & $_POST["locator_name"] != "" & $_POST["transfer_subinventory"] != "" & $_POST["transfer_locator"] != "" & $_POST["transaction_reference"] != "" & $_POST["reason_name"] != "" & $_POST["creation_date"] != "" & $_POST["created_name"] != "")
{
$c1 = OCILogon("apps","apps",$db);
$strSQL = "SELECT * From pt_mercury_material_trans where (transaction_date LIKE '%".$_POST["transaction_date"]."%' and item_number LIKE '%".$_POST["item_number"]."%'
and item_description LIKE '%".$_POST["item_description"]."%'
and transaction_type_name LIKE '%".$_POST["transaction_type_name"]."%'
and subinventory_code LIKE '%".$_POST["subinventory_code"]."%'
and locator_name LIKE '%".$_POST["locator_name"]."%'
and transfer_subinventory LIKE '%".$_POST["transfer_subinventory"]."%'
and transfer_locator LIKE '%".$_POST["transfer_locator"]."%'
and transaction_reference LIKE '%".$_POST["transaction_reference"]."%'
and reason_name LIKE '%".$_POST["reason_name"]."%'
and creation_date LIKE '%".$_POST["creation_date"]."%'
and created_name LIKE '%".$_POST["created_name"]."%') order by transaction_date , transaction_id";
$objParse = OCIParse($c1, $strSQL);
?>
.
.
.
.
.
<?
{
?>
ถ้าค้นหาหลายตัวจะขึ้นมาหมดคับตั้งแต่ตัวเดียวไปจนครบคับ
|
|
|
|
|
Date :
2010-03-19 10:40:38 |
By :
lukchang |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้การเชื่อม String ในส่วนของ SQL Statement ครับ
Code (PHP)
<?
$strSQL = "SELECT * FROM table WHERE 1 ";
if($_POST["txt1"] != "")
{
$strSQL .= " AND F1 = '".$_POST["txt1"]."' ";
}
if($_POST["txt2"] != "")
{
$strSQL .= " AND F2 = '".$_POST["txt2"]."' ";
}
?>
|
|
|
|
|
Date :
2011-07-26 16:22:06 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|