I have two tables in a database. Tablequestions, has two columns,ID and question. Table two answers has two columns question_ID and answer. In table answers there more than one answer pertaining to a question. So there are duplicate question_IDs. How do i display all questions from table questions with all the answers pertaining to it from table answers right under the question? Like:
How far is the sun?
The sun is 18 million miles away.
The sun is 93 million miles away.
The sun is 2 miles away.
How big is the sun?
Big.
Small.
Medium.
etc…
Sorry if the question seems a bit vague but its the best way i can explain it. Thanks in advance.
You would execute a select query that joins the two tables, ordering by the question id.
This will give you a result set like:
etc
When you loop through this result set you need to keep track of what the last question was so that when you go to the third result, question 2, you know to display the next question.
e.g.