01.
<html>
02.
<head>
03.
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
04.
</head>
05.
<body>
06.
<?php
07.
$objConnect
= mysql_connect(
"localhost"
,
"root"
,
"root"
)
or
die
(
"Error Connect to Database"
);
08.
$objDB
= mysql_select_db(
"mydatabase"
);
09.
$strSQL
=
"SELECT * FROM customer ORDER BY RAND() LIMIT 2 "
;
10.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
11.
?>
12.
<table width=
"600"
border=
"1"
>
13.
<tr>
14.
<th width=
"91"
> <div align=
"center"
>CustomerID </div></th>
15.
<th width=
"98"
> <div align=
"center"
>Name </div></th>
16.
<th width=
"198"
> <div align=
"center"
>Email </div></th>
17.
<th width=
"97"
> <div align=
"center"
>CountryCode </div></th>
18.
<th width=
"59"
> <div align=
"center"
>Budget </div></th>
19.
<th width=
"71"
> <div align=
"center"
>Used </div></th>
20.
</tr>
21.
<?php
22.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
23.
{
24.
?>
25.
<tr>
26.
<td><div align=
"center"
><?php
echo
$objResult
[
"CustomerID"
];?></div></td>
27.
<td><?php
echo
$objResult
[
"Name"
];?></td>
28.
<td><?php
echo
$objResult
[
"Email"
];?></td>
29.
<td><div align=
"center"
><?php
echo
$objResult
[
"CountryCode"
];?></div></td>
30.
<td align=
"right"
><?php
echo
$objResult
[
"Budget"
];?></td>
31.
<td align=
"right"
><?php
echo
$objResult
[
"Used"
];?></td>
32.
</tr>
33.
<?php
34.
}
35.
?>
36.
</table>
37.
<?php
38.
mysql_close(
$objConnect
);
39.
?>
40.
</body>
41.
</html>