question table
========================
question_id
1
2
3
4
user_answer table
========================
user_id question_id
33 2
44 4
33 1
44 3
This code will return the question id (2 and 1)
what I want is to retrieve the other question id from table question so I want
the result to be (3 and 4)
$fadi = mysql_query("SELECT * FROM question
LEFT OUTER JOIN user_answer
ON user_answer.question_id = question.question_id
WHERE user_answer.user_id = 33");
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array($fadi))
{ Print "<tr>";
Print "<th>question </th> <td>".$info['question_id'] . "</td></tr>";
} Print "</table>"; }
Edit: Improved version.
MySQLi version:
See in action: http://www.sqlfiddle.com/#!2/27b6f/21