01.
<html>
02.
<head>
03.
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
04.
</head>
05.
<script language=
"JavaScript"
type=
"text/JavaScript"
>
06.
<!--
07.
function
MM_jumpMenu(targ,selObj,restore){
08.
eval
(targ+
".location='"
+selObj.options[selObj.selectedIndex].value+
"'"
);
09.
if
(restore) selObj.selectedIndex=0;
10.
}
11.
12.
</script>
13.
<body>
14.
<form name=
"frmSearch"
method=
"post"
action=
"<?=$_SERVER['SCRIPT_NAME'];?>"
>
15.
<table width=
"599"
border=
"1"
>
16.
<tr>
17.
<th>Country Code
18.
<select name=
"ddlCountryCode"
id=
"ddlCountryCode"
onChange=
"MM_jumpMenu('parent',this,0)"
>
19.
<option>- Select Country Code -</option>
20.
<option value=
"<?=$_SERVER["
PHP_SELF
"];?>?Counter=TH"
>TH</option>
21.
<option value=
"<?=$_SERVER["
PHP_SELF
"];?>?Counter=EN"
>EN</option>
22.
<option value=
"<?=$_SERVER["
PHP_SELF
"];?>?Counter=US"
>US</option>
23.
</select>
24.
</th>
25.
</tr>
26.
</table>
27.
</form>
28.
<?
29.
30.
$objConnect
= mysql_connect(
"localhost"
,
"root"
,
"root"
)
or
die
(
"Error Connect to Database"
);
31.
$objDB
= mysql_select_db(
"mydatabase"
);
32.
33.
$strSQL
=
"SELECT * FROM customer WHERE 1 "
;
34.
if
(
$_GET
[
"Counter"
] !=
""
)
35.
{
36.
$strSQL
.=
" AND (CountryCode = '"
.
$_GET
[
"Counter"
].
"') "
;
37.
}
38.
39.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
40.
?>
41.
<table width=
"600"
border=
"1"
>
42.
<tr>
43.
<th width=
"91"
> <div align=
"center"
>CustomerID </div></th>
44.
<th width=
"98"
> <div align=
"center"
>Name </div></th>
45.
<th width=
"198"
> <div align=
"center"
>Email </div></th>
46.
<th width=
"97"
> <div align=
"center"
>CountryCode </div></th>
47.
<th width=
"59"
> <div align=
"center"
>Budget </div></th>
48.
<th width=
"71"
> <div align=
"center"
>Used </div></th>
49.
</tr>
50.
<?
51.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
52.
{
53.
?>
54.
<tr>
55.
<td><div align=
"center"
><?=
$objResult
[
"CustomerID"
];?></div></td>
56.
<td><?=
$objResult
[
"Name"
];?></td>
57.
<td><?=
$objResult
[
"Email"
];?></td>
58.
<td><div align=
"center"
><?=
$objResult
[
"CountryCode"
];?></div></td>
59.
<td align=
"right"
><?=
$objResult
[
"Budget"
];?></td>
60.
<td align=
"right"
><?=
$objResult
[
"Used"
];?></td>
61.
</tr>
62.
<?
63.
}
64.
?>
65.
</table>
66.
<?
67.
mysql_close(
$objConnect
);
68.
?>
69.
</body>
70.
</html>