-1
我需要過濾這些結果與c.statusRP =狀態打開如何將條件添加到WHERE子句中?
$query= mysql_query("SELECT h.id, h.sid, h.did, h.nextaction, h.nextactiondate, d.company, d.name, d.surname, c.company, d.balance, d.amount from History h, Person d, Client c where h.sid=c.ref and d.id=h.did and nextactiondate between $dayEnd and $dayStart order by c.company desc");
#print $tquery;
$mydate = date("d-m-Y");
$message = "<br><br><h1>Task List for $mydate</h1><br>";
$message .= "<table border=\"1\"><tr><strong><td>Customer Ref</td><td>Client Company</td><td>Customer Ref</td><td>Other Company</td><td>Full Name</td><td>Next Action</td></strong></tr>";
while ($def = mysql_fetch_row($query)) {
$sid = $def[1];
$did = $def[2];
$nextaction = $def[3];
$nextactiondate = $def[4];
$dcompany = $def[5];
$dname = $def[6];
$dsurname = $def[7];
$ccompany = $def[8];
$dbalance = $def[9];
$damount = $def[10];
if ($dbalance == "") {
$newbalance = $damount;
}
else {
$newbalance = $dbalance;
}
switch ($nextaction) {
我曾嘗試加入
$query= mysql_query("SELECT h.id, h.sid, h.did, h.nextaction,
h.nextactiondate, d.company, d.name,
d.surname, c.company, d.balance,
d.amount
from History h, Person d, Client c
where h.sid=c.ref
and d.id=h.did
and nextactiondate between $dayEnd and $dayStart
order by c.company desc
WHERE c.statusRP = 'Open';");
但隨後我上線的錯誤顯示這樣的:
while ($def = mysql_fetch_row($query)) {
我在做什麼錯了?
如果仔細觀察,您會看到原始查詢中有ALREADY WHERE子句。也許你應該尋找另一種熱情。或者閱讀一個SQL手冊,僅僅爲了它的樂趣 – RiggsFolly
格式化你的查詢,所以你可以真正理解它們是什麼 – RiggsFolly
錯誤是因爲查詢失敗 – RiggsFolly