ผมจะแยก mysql_query ของ WHERE ออกมาอีกที่ต้องทำไงครับ ผมใส่เป็น $res3 .=
มัน ขึ้นมาแบบนี้ครับ
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in
Code (PHP)
$res3 = mysql_query("SELECT COUNT(work_day.wday4) AS CDN_wday4
FROM work_day
LEFT JOIN work_d ON work_day.wd1=work_d.wd1
LEFT JOIN work_c ON work_d.wc1=work_c.wc1
LEFT JOIN work_b ON work_c.wb1=work_b.wb1
LEFT JOIN work_a ON work_b.wa1=work_a.wa1
LEFT JOIN profile ON work_day.id=profile.id
WHERE work_day.id='".trim(mysql_real_escape_string($id))."'
&& work_day.wday3 BETWEEN '$date_s3' AND '$date_f3'
&& work_day.wday11=''
");
$res3 .=" && work_a.wa0 = '".trim(mysql_real_escape_string($wa0))."'";
$row3 = mysql_fetch_object($res3);
mysql_free_result($res3);
$res3 = mysql_query("SELECT COUNT(work_day.wday4) AS CDN_wday4
FROM work_day
LEFT JOIN work_d ON work_day.wd1=work_d.wd1
LEFT JOIN work_c ON work_d.wc1=work_c.wc1
LEFT JOIN work_b ON work_c.wb1=work_b.wb1
LEFT JOIN work_a ON work_b.wa1=work_a.wa1
LEFT JOIN profile ON work_day.id=profile.id
WHERE work_day.id='".trim(mysql_real_escape_string($id))."'
&& work_day.wday3 BETWEEN '$date_s3' AND '$date_f3'
&& work_day.wday11=''
");
$res3 .=" && work_a.wa0 = '".trim(mysql_real_escape_string($wa0))."'";
บันทัดข้างบนเอา string ไปทับค่า $res3; ทำไห้ $res3 มี type เป็น string ไม่ใช่ object
$row3 = mysql_fetch_object($res3);
mysql_free_result($res3);
$sql = "SELECT COUNT(work_day.wday4) AS CDN_wday4
FROM work_day
LEFT JOIN work_d ON work_day.wd1=work_d.wd1
LEFT JOIN work_c ON work_d.wc1=work_c.wc1
LEFT JOIN work_b ON work_c.wb1=work_b.wb1
LEFT JOIN work_a ON work_b.wa1=work_a.wa1
LEFT JOIN profile ON work_day.id=profile.id
WHERE work_day.id='".trim(mysql_real_escape_string($id))."'
&& work_day.wday3 BETWEEN '$date_s3' AND '$date_f3'
&& work_day.wday11=''
";
$sql .=" && work_a.wa0 = '".trim(mysql_real_escape_string($wa0))."'";
$res3 = mysql_query($sql) or die(mysql_error() . "<br>$sql");
$row3 = mysql_fetch_object($res3);
mysql_free_result($res3);