Monday 1 August 2016

Mysql Databse with php

By,
Dinesh



MySQL is the popular Open Source Relational SQL database management system. MySQL is RDBMS being used for developing web-based applications.
MySql is used for a scripting language like PHP is because of the interaction with databases it can offer.PHP and the MySQL database to store information on the web and include it into your website. If you have least a basic knowledge of how to use PHP we can use MySql database.
Why use database?
Database is very useful to any website. There are a huge variety of things we can do when we can display simple lists to running a complete website from a database.


We need three things to run PHP scripts which access MySQL databases.
1.web server: local host or web host
PHP also needs to be installed on the server.or use xamp,wamp,lamp local sever which can install on your computer.

2. MySQL. This is the actual database software.
You can also use other types of database such as SQL, Oracle, Postgresql etc. MySQL is free and can be downloaded from the MySQL homepage.
The process of setting up a MySQL database, fill a database name, a user name and a password for user identification. This information will be required to login to the database section.
If you have PHPMyAdmin installed you can just go to it to log in with your user name and password. If not done then you must do all your database administration using PHP scripts.
1. Create a table.
2.  A table is for storing related information.
3. in PHPMyAdmin is simple, just type the name, select the number of fields
4. You will be on to a setup screen where you must create the fields for the database.
5. If you are using a PHP language to create your database the whole creation and setup will be done in   one command.

Field Type
Description
1.TINYINT
Small Integer Number
2.SMALLINT
Small Integer Number
3.MEDIUMINT
Integer Number
4.INT
Integer Number
5.VARCHAR
Text (maximum 256 characters)

To create table:
CREATE table table_name
{
Fields;
}
Php database connection is like this:
mysql_connect(localhost,$username,$password);
then you have connected to the database server you must then select the database you wish to use for storage. This must be a database to which your username/database has access. The following command is:

@mysql_select_db($database) or die( "Unable to select database");
to insert any input data you have to write a query which store data in database
1.  $query=”INSERT INTO table tbl_name (column) Values (‘value’)”;
2. mysqli_query($conn,$query);

No comments:

Post a Comment