-1
由於我是新來的PHP,我發現這個極其複雜的解決。我有這個查詢顯示用戶不應該這樣做的結果。多表查詢加入
的問題是銷售代理能夠看到他沒有被授權的用戶看到的投訴。這涉及用於客戶的賬戶表。
$priv = "dire problem" ,
$naone = "not serious" ,
$priv2 = "mild prblem"
are sorting conditions.
$aid is the agent viewing this page.
Complaints is for complaints by the customers.
Accounts table holds all the customer information.
Agents table is for all the sales/customer reps.
代碼:
$sql = "SELECT complaints.complaint_id, accounts.full_name,
agents.agent_name, complaints.person_id, complaints.why_complaint,
complaints.just_date, complaints.type, complaints.date_time_added FROM
complaints LEFT JOIN accounts ON complaints.person_id = accounts.person_id
LEFT JOIN agents on complaints.agent_whois = agents.agent_id WHERE
(complaint_type = '$priv' OR complaint_type = '$naone' OR complaint_type = '$priv2') and
(complaints.added_by <> '$aid')";
$result=mysql_query($sql);
$query = mysql_query($sql) or die ("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$complaintid = $row['complaint_id'];
$agentwho = $row['person_id'];
$agentname = $row['agent_name'];
$reason = $row['why_complaint'];
$datetimeadded = $row['just_date'];
$docname = $row['full_name'];
$type = $row['type'];
print("");
}
}
你想解決什麼問題? – str
我與這個問題ediiting它 – AAA
困惑,你試圖限制視圖只顯示那些已被分配給該代理,或者是你想將其限制在經許可的一級代理商? – espradley