Thursday 20 August 2015

Create Database with MySql and INSERT coding in php

It is basics of PHP, here we are going to see about How to create database and how insert the field values in the database table. for that just follow the below instruction what i given below. as per this just follow to create database and insert in it,

Database Creation:

 Here I’m using WAMP sever, so just go to the localhost as url, and choose phpmyadmin and click on the Database, and fill the name of your database, and click Create.

And the database will be created as the name what we given, 


After the database created, we have to create a table. Name of the table and number of columns we want, and click Go.



The above field will be comes like, how many columns we want. fill all the fields without fail.

 

We have to fill the fields, and click save to finish the table creation

 

And the database and table creation work is over.

Sample form image

 Here we are going to insert values so here we need db.php file mainly,

refer all the above for the database name, database table name, and column name and types. now just follow the coding.

DB.PHP

<?php
$conn=mysql_connect("localhost","root","")or die('Database not connected');
$db=mysql_select_db("downdrop")or die('Database not connected');
?>


And the insert coding comes on the main page

INSERT.PHP

<?php
if(isset($_POST['submit']))
{
 $name=$_POST['namename'];
 $number=$_POST['numbername'];
 $address=$_POST['addname'];
 $insert=mysql_query("insert into ddtable(name,number,address)
values
('$name','$number','$address')");
}
?>


All finished, click on the submit button the result will be comes like,
And finish of Creating Database and Insert coding here.

If you have any problem regarding this tutorial configuration please feel free to comment we love to answer your queries.

No comments:

Post a Comment