<?
require("connect.php");
$result=mysql_create_db($db,$connect);
echo "Create database perlphpasp : ";
if ($result) { echo "Ok"; } else { echo "Error"; }
# =======
echo "<hr>Create table ohotb : ";
$query="create table ohotb (id char(4),descp char(40))";
$result=mysql_db_query($db,$query);
if ($result) { echo "Ok"; } else { echo "Error"; }
# =======
echo "<hr>Create records : ";
$query="insert into ohotb values('1001','Business computer')";
$result = mysql_db_query($db,$query); echo $result;
$query="insert into ohotb values('1002','Computer engineering')";
$result = mysql_db_query($db,$query); echo $result;
$query="insert into ohotb values('1003','Computer science')";
$result = mysql_db_query($db,$query); echo $result;
$query="insert into ohotb values('1004','Information technology')";
$result = mysql_db_query($db,$query); echo $result;
# =======
echo "<hr>Display records : <br>";
$query="select * from ohotb";
$result = mysql_db_query($db,$query);
while ($object = mysql_fetch_object($result)) {
echo $object->id . " " . $object->descp . "<br>";
}
$cnt= mysql_num_rows($result);
echo $cnt;
# =======
echo "<hr>Drop database : ";
$result=mysql_drop_db($db,$connect);
if ($result) { echo "Ok"; } else { echo "Error"; }
mysql_close($connect);
?>
จำนวน : 35 บรรทัด