<?
require("connect.php");
$tb = "enttype";
$result = mysql_db_query($db,"select * from $tb");
if ($result) {
echo "Clear all records : ";
$query="delete from $tb";
} else {
echo "Create $tb : ";
$result=mysql_create_db($db,$connect);
$query="create table $tb (idtype char(4),descp char(40))";
}
$result=mysql_db_query($db,$query);
if ($result) { echo "Ok"; } else { echo "Error"; }
# ======
$query="insert into enttype values('1001','Business computer')";
$result = mysql_db_query($db,$query);
$query="insert into enttype values('1002','Computer engineering')";
$result = mysql_db_query($db,$query);
$query="insert into enttype values('1003','Computer science')";
$result = mysql_db_query($db,$query);
$query="insert into enttype values('1004','Information technology')";
$result = mysql_db_query($db,$query);
# =======
$result = mysql_db_query($db,"select * from $tb");
$cnt= mysql_num_rows($result);
echo "<br>Restore $tb $cnt records : Ok";
mysql_close($connect);
?>
จำนวน : 29 บรรทัด