PHP do not provide the special function of making tables with its fields. So in order to make the data table, it stills use the sintaks from database program (used MySQL) then this sintaks will be operated by using of mysql_query() function.
For example, make a employees database of one office, personal data table with the field of employees number, employees name, and employees address.
Create a file named create_table.php within www. Enter following code:
<?php
//the example of making MySQL database table
//create_table.php
$continued = mysql_connect("localhost","root","");
if($continued){
echo("Connection is succeed");
}else{
echo("Connection is fail");
}
$make = mysql_query("CREATE DATABASE employees",$continued);
if($make){
echo("<br><br>Employees database succeeds in making");
}else{
echo("<br><br>Employees database fails in making");
}
$order1 = "CREATE TABLE data_employees
(
employees_number int(10)AUTO_INCREMENT PRIMARY KEY,
name char(100),
address varchar(255)
)";
mysql_select_db("employees");

$make_table = mysql_query($order1);
if($make_table){
echo("<br><br>Table data_employees succeeds in making");
}else{
echo("<br><br>Table data_employees fails in making");
}
?>

0 comments:

Post a Comment

 
Top
Blogger Template