I'm creating a quiz script so that a user can enter a quiz name, and then add questions and answers to that quiz.
I have an SQL statement where I join 2 tables (questions and answers), and which is part of a query that echoes out criteria that matches the SQL. I need to change the SQL statement so that it also only prints out the data if it matches data in a column from the table holding the quiz name, i.e it only prints out the questions and answers for that particular quiz.
This is what I thought it would be, but it doesn't work. It keeps printing out the answers from all of the quizes.
$query2 = "SELECT questions.questionno, questions.question, questions.quizref, questions.questionref, answers.answerno, answers.answer, answers.answervalue, answers.questionno, answers.quizref, answers.answerref FROM questions JOIN answers ON questions.questionno = answers.questionno WHERE questions.questionno = ".$row['questionno']. "AND answers.quizref = ".$id;
Any help would be great
Thanks