-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