|
 |
|
รบกวนช่วยดูโคดหน่อยครับ ทำไมค่ามันไม่ออกครับ ช่วยทีนะครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
$sql='';
if (isset($_POST['sub1']))
{
$t1 = 'SUBJECT '.$t1;
$datel = date("Y:m:d");
$timel =date("H:i:s");
$name = $_SESSION['User_Loginnew']['user_name'];
$actt = "SEARCH DOC";
$datet = date("Y-m-d").' '.date("H:i:s");
$pc="INSERT INTO logdb(log_name,log_date,log_time,log_file,log_act) VALUES ('$name','$datel','$timel','$t1','$actt')";
$precon2 = mysql_query($pc);
$cond = array();
// search case
if (!empty($_POST['t1']))
{ $cond[] = 'doc_about like "%'.$_POST['t1'].'%"'; }
// date t2 only case
if (!empty($_POST['t2']))
{
$tdate1 = date('Y-m-d', strtotime($_POST['t2']));
$cond[]='doc_date >= "'.$tdate1.'" ';
}
// date tex3 only case
if (!empty($_POST['tex3']))
{
$tdate2 = date('Y-m-d', strtotime($_POST['tex3']));
$cond[]='doc_date <= "'.$tdate1.'" ';
}
// 2 date case
if (!empty($_POST['t2'])&& !empty($_POST['tex3']))
{
$tdate1 = date('Y-m-d', strtotime($_POST['t2']));
$tdate2 = date('Y-m-d', strtotime($_POST['tex3']));
$cond[]='doc_date between "'.$tdate1.'" and "'.$tdate2.'"';
}
//statusfile 1-3 1= all 2=normally 3=delete
//case statusfile = 2
if ($_POST['statusfile']==2) { $cond[] = 'doc_status = normally';}
//cser statusfile = 3
if ($_POST['statusfile']==3) { $cond[] = 'doc_status = delete';}
//uncheckbox case
if (empty($_POST['checksearch']))
{ $cond[]='doc_ref = 0'; }
//checkbox case
if (!empty($_POST['checksearch']))
{
$cond[]='OR doc_ref = ( SELECT doc_id FROM document WHERE "'.$cond.'") ';
}
//check arry
if (count($cond) > 0) // case have some
{ $conds = join(" and ",$cond); }
if (count($cond) == 1) // case have one
{ $conds = " where ".$cond[0]; }
else // case cond == 0
{ $conds ="";}
$sql = $sql='select * ,type_name from document left join doctype on document.doc_type = doctype.type_id'.$conds;
}
if(!empty($sql)){
$dbquery=mysql_query($sql);
$num_rows=mysql_num_rows($dbquery);
$_SESSION['sqlm']=$sql;
echo $conds;
echo $sql;
}
?>
ค่ามันไปลงที่ $conds = 0 ตรงเอลตลอดเลยอะครับ ทั้งๆ ที่ผมใส่ค่าในเทคบ๊อกแล้วนะครับ
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2014-09-25 10:39:24
|
 |
 |
 |
 |
Date :
2014-09-25 10:00:52 |
By :
summawat |
View :
700 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

ไล่ Debug Query ดีกว่าครับ แล้วเอาไปรันบน phpMyAdmin ดูครับ
|
 |
 |
 |
 |
Date :
2014-09-25 17:13:36 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|