How to Create Table using PHP MySQLi
PHP MySQLi Table Creation |
Hi Guys In This Tutorial i will Show you How to Create a Table Using PHP MySQLi.
You are going to create table "test".
Database Name: tutorial
Table Name: test
Create a new file table.php in htdocs folder.
Codes for table.php
<?php $host = "localhost";//Host Name $username = "root"; //MySQL User name(root is Default) $password = ""; //MySQL Password(If Protected) $db_name="tutorial"; // Creating connection with Server passing host,username and password $conn = new mysqli($host, $username, $password,$db_name); // Checking connection if ($conn->connect_error) { die("Sorry Failed to Connect: " . $conn->connect_error); } // sql query to create table "test" $sql = "CREATE TABLE sfsdf( id int(11) NOT NULL AUTO_INCREMENT, name varchar(150) NOT NULL, email varchar(150) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;"; if ($conn->query($sql) === TRUE) { echo "Your Table test successfully Created"; } else { echo "Sorry Error creating table: " . $conn->error; } $conn->close(); ?>
If you Like This article Please Like and Share With Your Friends.
Keep Visiting for More Codes.Thank you.
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.