|
 |
|
ทำไมทำใส่คำสั่งให้มีคำว่า and เพื่อเชื่อมคำสั่งในการเรียกข้อมูลแล้วแต่ทำไมมันขึ้นมาแค่ส่วนเดียวละครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
$command = $_GET["command"];
{
include("connect.php");
$status = $_GET["status"];
$txtKeyword = $_GET["txtKeyword"] ;
$url = '&txtKeyword='. $_GET["txtKeyword"] ;
//; //แสดงข้อความออกมา จำนวนstatus
for($i=0;$i<count($_GET["status"]);$i++)
{
//if(trim($_GET["status"][$i]) != "");
$url .= '&status[]='. $_GET['status'];
}
$search_condition = "where ";
if(trim($txtKeyword)) { $search_condition .= "( a.p_id LIKE '%$txtKeyword%'or a.p_stu_fname LIKE '%$txtKeyword%' or a.p_stu_sname LIKE '%$txtKeyword%' or a.p_adv_fname LIKE '%$txtKeyword%' or a.p_adv_sname LIKE '%$txtKeyword%' )" ;
}
if (!empty($txtKeyword) && count($status)!=0) {
$search_condition .= " and ";
}
if (count($status)!=0) {
$search_condition .= "a.p_sta_key IN ('". implode("','", $status) . "')";
}
$sql = " select a.* ,b.p_num,c.p_adv_num , c.p_adv_fname , c.p_adv_sname, d.p_sta
from senior_n a left join senior_num b on (a.p_numkey = b.p_numkey)
left join senior_adv c on (a.p_adv = c.p_adv)
left join senior_sta d on (a.p_sta_key = d.p_sta_key)
$search_condition ";
$objQuery = mysql_query($sql) or die ("Error Query [".$sql."]");
$Num_Rows = mysql_num_rows($objQuery);
พี่ๆๆช่วยแนะทีครับ
Tag : PHP, MySQL, Action Script, CakePHP

|
ประวัติการแก้ไข 2012-08-15 00:20:52
|
 |
 |
 |
 |
Date :
2012-08-14 21:55:35 |
By :
crazydrogon |
View :
888 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองไล่ดูเงื่อนไขดี ๆ อีกครั้งครับ 
|
 |
 |
 |
 |
Date :
2012-08-15 06:38:21 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|