Follow the step
Step
1: Create Database and table.
Step2:
Enter hostname, Database name.
Step3:Insert
Data and Execute the Query.
This is
my database and my database name is registration and table name is user.
We are
inserting a data statically(already data
is selected).
<?php
$username = "root";
$password = "";
$hostname =
"localhost";
$database_name='registration';
$password=” ”;
$dbhandle = mysqli_connect('localhost',$username ,$password,$database_name)
or die("Unable to connect
to MySQL");
$name ="Gaurav";
$password1="1234";
$email="gauravrautela123@gmail.com";
$query="insert into user set name='".$name."',password='".$password1."',
email='".$email."'";
$execute = mysqli_query($dbhandle, $query);
$execute = mysqli_query($dbhandle, $query);
If($execute)
{
echo "Congrats Data
inserted";
}else{
echo "Something Going Wrong";
}
?>
Terminology:
mysqli_connect():
It is php connection method,we can pass four argument hostname,username,password,Database name.
Die();It
stop the rest of exection if die methiod will exectute and show the
messages.
it is really a great tutotrial.. plz keep posting more blogs.
ReplyDeleteNice tutotrial you are gaurav rautela,,,good job,,excellent,, keep posting more blogs so that we can get more knowledge.
ReplyDeleteThis Blog is Very Helpful .Great Job Gaurav Rautela Keep it Up...Keep Posting More Blogs ..
ReplyDeleteThis blogs solves my problem ..Very thankful to Gaurav Rautela Keep it up ...keep posting more ...
ReplyDeleteGreat explanation...Buddy..
ReplyDeletenice blog bro it is very helpful..............................good job
ReplyDelete