"and table.field = '$ filter'또는 table.field = '$ otherfilter'"를 삭제하면 아래 쿼리가 올바르게 작동합니다. 이 부분을 추가하면 볼 수있는 권한이없는 사람들에게 결과가 표시됩니다. 필자는 필터링 된 결과를 보여주기 위해 그 부분을 확실히 추가해야합니다.이 쿼리가 필터를 무시하는 이유는 무엇입니까?
코드 'otherfilter $'와 table.field = '$ 필터'OR table.field = : 나는 그래서 나에게 올바른 사용 결과를 보여줍니다이의 구조를 어떻게
//$filter = "23943409"
$filter2 = "$username";
$sql = "SELECT table.field, table2.field, table.field, table.field,
table.field, table.field, table.field FROM table
LEFT JOIN table2 ON table.field = table2.field
WHERE table.field='$id' and table.field='$id'
and table.field = '$filter' OR table.field='$otherfilter'
ORDER BY table.id DESC LIMIT 0, 3";
$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))
{
$field = $row['field'];
print("$field");
}
}
귀하는 $ filter를 (를) 주석 처리 했으므로이 변수는 비어 있습니다. 따라서 쿼리는 다음과 같이됩니다. table.field = '' – bart