Complete Computer Knowledge Portal

Showing posts with label PHP Programming. Show all posts
Showing posts with label PHP Programming. Show all posts

Monday, December 9, 2013

Retrieving Data from MYSQL Database using PHP


Using these easy steps you can easily retrieve the data from MYSQL database. In this example I am assuming that you have already created MYSQL database and already contains some tabular data.
Create database named mydb
CREATE DATABASE `mydb`;

Create Table student on mydb Database:
Table info is created with three fields: id, name and Email Address. Id will be automatically incremented after every insert operation.
CREATE TABLE `mydb`.`student` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 100 ) NOT NULL ,
`contact_no` int( 20 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM

Insert some raw data for Accessing
INSERT INTO `mydb`.`student` (`id`, `name`, `contact_no`) VALUES (NULL, 'Dashmesh', '123456');

How to insert PHP Form data into MYSQL Database?

Here are some easy steps that are used to insert PHP data into MYSQL database
      1) Create MYSQL database
           2) Create index.php or index.html page with required inputs.
           3) PHP script to insert data.
           4) Database connection
Create the database testing
CREATE DATABASE `testing`;
 
Create Table info on testing Database:
Table info is created with three fields: id, name and Email Address. Id will be automatically incremented after every insert operation.
CREATE TABLE `testing`.`info` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 100 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM