001.
<!doctype html>
002.
<html lang=
"en"
>
003.
<head>
004.
<meta charset=
"UTF-8"
>
005.
<meta name=
"Generator"
content=
"EditPlus®"
>
006.
<meta name=
"Author"
content=
""
>
007.
<meta name=
"Keywords"
content=
""
>
008.
<meta name=
"Description"
content=
""
>
009.
<title>Data Communication & Network</title>
010.
</head>
011.
<body>
012.
<form name=
"form1"
method=
"post"
action=
"checkAnswer.php"
>
013.
<?php
require_once
(
'connect/connectq.php'
); ?>
014.
<?php
015.
016.
$strSQL
=
"SELECT * FROM question ORDER BY RAND() LIMIT 5"
;
017.
$objQuery
=mysqli_query(
$objCon
,
$strSQL
);
018.
?>
019.
<?php
020.
021.
$i
=0;
022.
$num
=0;
023.
while
(
$objResult
= mysqli_fetch_array(
$objQuery
,MYSQLI_ASSOC))
024.
{
025.
$i
++;
026.
$num
=
$num
+1;
027.
$c1
=
$objResult
[
"ans1"
];
028.
$c2
=
$objResult
[
"ans2"
];
029.
$c3
=
$objResult
[
"ans3"
];
030.
$c4
=
$objResult
[
"ans4"
];
031.
$arr
=
array
(
$c1
,
$c2
,
$c3
,
$c4
);
032.
shuffle(
$arr
);
033.
if
(
$arr
[0]==
$c1
){
034.
$a
=1;
035.
}
036.
if
(
$arr
[0]==
$c2
){
037.
$a
=2;
038.
}
039.
if
(
$arr
[0]==
$c3
){
040.
$a
=3;
041.
}
042.
if
(
$arr
[0]==
$c4
){
043.
$a
=4;
044.
}
045.
if
(
$arr
[1]==
$c1
){
046.
$b
=1;
047.
}
048.
if
(
$arr
[1]==
$c2
){
049.
$b
=2;
050.
}
051.
if
(
$arr
[1]==
$c3
){
052.
$b
=3;
053.
}
054.
if
(
$arr
[1]==
$c4
){
055.
$b
=4;
056.
}
057.
if
(
$arr
[2]==
$c1
){
058.
$c
=1;
059.
}
060.
if
(
$arr
[2]==
$c2
){
061.
$c
=2;
062.
}
063.
if
(
$arr
[2]==
$c3
){
064.
$c
=3;
065.
}
066.
if
(
$arr
[2]==
$c4
){
067.
$c
=4;
068.
}
069.
if
(
$arr
[3]==
$c1
){
070.
$d
=1;
071.
}
072.
if
(
$arr
[3]==
$c2
){
073.
$d
=2;
074.
}
075.
if
(
$arr
[3]==
$c3
){
076.
$d
=3;
077.
}
078.
if
(
$arr
[3]==
$c4
){
079.
$d
=4;
080.
}
081.
082.
?>
083.
<table width=
"64%"
border=
"1"
align=
"center"
>
084.
<tr>
085.
<td width=
"14%"
><div align=
"center"
>
086.
<?=
"$num"
;?>
087.
</div></td>
088.
<td width=
"86%"
><div align=
"left"
>
089.
<input name=
"id<? =$i; ?>"
type=
"hidden"
value=
"<?=$objResult["
idq
"];?>"
>
090.
<br>
091.
<?=
$objResult
[
"question"
];?>
092.
093.
<br>
094.
<input type=
"radio"
id=
"c<?=$i;?>"
name=
"c<?=$i;?>"
value=
"<?php echo $a;?>"
> <?=
$arr
[0];?>
095.
<br>
096.
<input type=
"radio"
id=
"c<?=$i;?>"
name=
"c<?=$i;?>"
value=
"<?php echo $b;?>"
> <?=
$arr
[1];?>
097.
<br>
098.
<input type=
"radio"
id=
"c<?=$i;?>"
name=
"c<?=$i;?>"
value=
"<?php echo $c;?>"
> <?=
$arr
[2];?>
099.
<br>
100.
<input type=
"radio"
id=
"c<?=$i;?>"
name=
"c<?=$i;?>"
value=
"<?php echo $d;?>"
><?=
$arr
[3];?>
101.
<br>
102.
<input name=
"anstrue<?=$i;?>"
type=
"hidden"
value=
"<?=$objResult["
anstrue
"];?>"
>
103.
104.
</div></td>
105.
106.
</tr>
107.
</table><br>
108.
109.
<div align=
"center"
><br>
110.
<input type=
"hidden"
id=
"line"
name=
"line"
value=
"<? = $i; ?>"
>
111.
<input type=
"submit"
name=
"Submit"
value=
"ตรวจคะแนน"
>
112.
</div>
113.
</form>
114.
</body>
115.
</html>
116.
<?php
117.
}
118.
mysqli_close(
$objCon
);
119.
?>