0
필자의 필요에 맞는 쿼리를 생성 할 수있었습니다. 그러나 이제 쿼리가 각각의 결과와 모든 결과를 두 번 반복하는 결과를 표시하는 현재의 방법을 고려할 때 문제가 발생합니다. 한 번 보여 주던 곳에서 어떻게 올바르게 작동하게 할 수 있습니까?이 쿼리가 동일한 결과를 두 번 인쇄하지 못하게하는 방법은 무엇입니까?
코드 대신 mysql_fetch_array()
사용 mysql_fetch_assoc()
를 사용
$sql = "SELECT DISTINCT contacts.contact_id, user_accounts.full_name,
contact_notes.note_name, contact_notes.type, contact_notes.note_id,
contact_posts.why_post, contact_posts.type, contact_posts.post_id
FROM contacts, user_accounts, contact_notes, contact_posts
WHERE (contacts.system_id = '$sid' AND contacts.contact_id =
user_accounts.system_id AND contact_notes.user_allowed = '$everybody' AND
contact_posts.user_allowed = '$everybody') OR (contacts.contact_id = '$sid'
AND contacts.system_id = user_accounts.system_id AND contact_notes.user_allowed
= '$everybody' AND contact_posts.user_allowed = '$everybody')
LIMIT $startrow, 20";
$query = mysql_query($sql) or die ("Error: ".mysql_error());
$result = mysql_query($sql);
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$noteid = htmlspecialchars($row['note_id']);
$note_title = htmlspecialchars($row['note_name']);
$postid = htmlspecialchars($row['post_id']);
$postreason = htmlspecialchars($row['why_post']);
$datetimeadded = htmlspecialchars($row['just_date']);
print("<br /> <br />$note_title - $noteid <br /><br />$postreason - $postid");
}
}
안녕하세요, 여전히 쿼리를 두 번 반복합니다. – ariel
이봐, 아직 도움이 필요해. mysql_fetch_assoc()을 사용하면 같은 문제가 발생합니다. – ariel