Create Table Mysql PHP

Advertisements

PHP Create Database MySQL Insert Record in Database using PHP

Create Table Mysql PHP

Table is the collection of row and column, using below SQL query we can create own table in database.

Create Table in database

create table table_name (
id int(5) NOT NULL auto_increment,,
f_name varchar(20)
l_name varchar(20)
)

For create table in database using PHP webpage; first conncet to database then use below code.

connect-db.php

Connect to database

<?php

$server = 'localhost';
$user = 'user_name';
$pass = 'password';
$db = 'database_name';

// Connect to Database

$connection = mysqli_connect($server, $user, $pass)
or die("Could not connect to server ... \n" . mysqli_error ());

// select database
mysqli_select_db($db)
or die("Could not connect to database ... \n" . mysqli_error ());

?>

create-table.php

Create Table in database

<?php

include 'connect-db.php';

$sql = "id int(5) NOT NULL auto_increment, f_name varchar(20), l_name varchar(20)";
$result = mysqli_query($conn, $sql);

if($result) 
{
 echo "Table user created successfully......";  
}
else 
{
echo "Could not create table: ". mysqli_error($conn);  
}  
  
mysqli_close($conn);

?>

Output

Table user created successfully......

PHP Create Database MySQL Insert Record in Database using PHP

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Download Projects

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements