I'm not sure that I fully understand your problem. Your query is looking for question/answer pairs. If six answers have the same question, then that question will appear six times in the pairs.
You have two options.
- Use two queries. First use a query to return all the questions:
$query1 = "SELECT question_ID, question_text ".
"FROM question ".
"ORDER BY question_ID";
$result1 = mssql_query($query1) or die('Select Query Error');
Then when you are looping through the results of that query, nest in a second query to get the answers for that question:
// Display Question Results
while($row = mssql_fetch_array($result1))
{
$query2 = "SELECT answer_text ".
"FROM answer ".
"WHERE question_ID = " .$row['Question_ID'];
$result2 = mssql_query($query2) or die('Select Query Error');
}
Now you have the answers for this qurstion and you can display them any way you like.
The second option is just to not print the question if it's the same as the previous one you printed, and control the output in the PHP