Hi guys.

I wanted to create a quiz for my website. I have found some code from a website called (getcode.org) (prev world of webcraft).

The quiz now works as it should and I'm very happy it does. There is one problem I have adapited it to the needs of my website. The website is an learning aid for people like myself who suffer from Dyscaculia and its foucing on Fractions. I have added in 80 question into the database and at the moment the PHP/SQL code is selecting all of the question from the database.

I only want each quiz to contain 20 questions per quiz.


Code:
$singleSQL = mysql_query("SELECT * FROM questions WHERE id='$question' LIMIT 1");
		while($row = mysql_fetch_array($singleSQL)){
			$id = $row['id'];
			$thisQuestion = $row['question'];
			$type = $row['type'];
			$question_id = $row['question_id'];
			$q = '<h2>'.$thisQuestion.'</h2>';
			$sql2 = mysql_query("SELECT * FROM answers WHERE question_id='$question' ORDER BY rand()");
			while($row2 = mysql_fetch_array($sql2)){
				$answer = $row2['answer'];
				$correct = $row2['correct'];
				$answers .= '<label style="cursor:pointer;"><input type="radio" name="rads" value="'.$correct.'">'.$answer.'</label> 
				<input type="hidden" id="qid" value="'.$id.'" name="qid"><br /><br />
				';
				
			}
			$output = ''.$q.','.$answers.',<span id="btnSpan"><button onclick="post_answer()">Submit</button></span>';
			echo $output;
Is there anyway, how I can just state in the SQL code to only select 20 questions from the "questions" table and to have them in a random order so each quiz will contain 20 different questions each time a user takes the quiz?

Here is the specific line of code that is the concern

This is taking the questions from the questions table

Code:
$singleSQL = mysql_query("SELECT * FROM questions WHERE id='$question' LIMIT 1");
And this is the code that is taking the answers from the answers table and putting the answers in a ramdom order each time the questions are displayed

Code:
$sql2 = mysql_query("SELECT * FROM answers WHERE question_id='$question' ORDER BY rand()");
Any help would be much appreciated