222
Programming Languages for mis
$conn=mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("studentdb") or die(mysql_error());
echo("studentdb has been selected!");
echo("<br>");
$sql="DROP TABLE tblStudent";
mysql_query($sql);
mysql_close($conn);
echo("Table tblStudent has been deleted!");
?>
7.8.3 Insert Data to Table
Once the table is created, you can add data to the table by using PHP programs.
Listing7.18 is an example of a PHP program (InsertData.php) to insert three
records of student data in the tblStudent table. e mysql _ query() function is
used to process the SQL script. e script used here is slightly different from the stan-
dard format in that the attributes of the table are listed here (see lines 9, 13, and ...