Sorry, JonsJava.
<html>
<head>
<title></title>
</head>
<body>
<?php
echo' <table width="560" border="0" cellspacing="0" cellpadding="0">';
$answer = array();
//
$question_type = array();// I know I'd have been better with a 2D array here.
$question_s = array();
$question_d = array();
$question_th = array();
$question_tm = array();
$cntr = 0;
$nos = 10;
for ($i = 0; $i < $nos; $i++) { // There are 10 questions
$type = rand(1,1); // Questions are SDT. To simplify, ony posted code for Distance.
if ($type == 1) {
$question_type[$i]="distance";
//distance
do {
$speed = rand(10, 40);
do {
$timeh = rand(0, 3);
$timem = rand(0, 3);
} while ($timeh == 0 and $timem == 0);
$time = $timeh + ($timem * 0.25);
$a = $speed * $time;
} while ($a <> intval($a)); // Just ensuring that the calculated distance is an integer value
$answer[$i] = $a;
$time = "";
if ($timeh == 1) {
$time = $timeh . ' hour';
}
if ($timeh > 1) {
$time = $timeh . ' hours';
}
if ($timeh > 0 and $timem > 0) {
$time = $time . ' ';
}
if ($timem > 0) {
$timem = $timem * 15;
$time = $time . $timem . ' minutes';
}
echo '<tr><td width="480" height="20"></p><tr><td width="400" height="20"> '. 'At ' . $speed . ' mph, how far would you travel in '.$time . '? '.'</td>'; // asking the question
echo '<td width="160"> <input name="b'.$i.'" type="text" id="b1" size="6" maxlength="3"> miles '.$answer[$i].'</td></tr>'; // form field for the answer
}
$question_d[$i]=$distance;
$question_s[$i]=$speed;
$question_th[$i]=$timeh;
$question_tm[$i]=$timem;
}
echo' </table>';
?>?>
</body>
</html>
I'm trying to find a way of telling the user how many questions they got correct out of 10, and display the original questions and answers.
Again, many thanks for any help anyone can give.