01.
<?
include
"connect.php"
; ?>
04.
<head>
05.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
06.
<title>ข้อมูลนักเรียน</title>
07.
</head>
08.
09.
<body>
10.
<form method=
"get"
action=
"test.php"
>
11.
ชั้น ป.<select name=
"class"
>
12.
<option>1</option>
13.
<option>2</option>
14.
<option>3</option>
15.
<option>4</option>
16.
<option>5</option>
17.
<option>6</option>
18.
</select>
19.
<input type=
"submit"
/>
20.
</form>
21.
<table border=
"1"
>
22.
<tr>
23.
<td>รหัสนักเรียน</td>
24.
<td>ชื่อนักเรียน</td>
25.
<td>นามสกุลนักเรียน</td>
26.
<td>ชั้น</td>
27.
<td>ห้อง</td>
28.
</tr>
29.
<?
30.
$class
=
$_GET
[
'class'
];
31.
$sql
=
"select * from student where std_class like '$class'"
;
32.
$data
=mysql_db_query(
$dbname
,
$sql
)
or
die
(mysql_error());
33.
while
(
$row
=mysql_fetch_array(
$data
)){?>
34.
<tr>
35.
<td><?=
$row
[
'std_id'
];?></td>
36.
<td><?=
$row
[
'std_name'
];?></td>
37.
<td><?=
$row
[
'std_lname'
];?></td>
38.
<td><?=
$row
[
'std_class'
];?></td>
39.
<td><?=
$row
[
'std_room'
];?></td>
40.
41.
</tr>
42.
<? }?>
43.
44.
<tr>
45.
46.
</tr>
47.
</table>
48.
</body>
49.
</html>