Skip to main content

MySQL: Introduction

MySOL is a database. With PHP, default database is MySQL. Database is needed to create any dynamic website or web application. Records or information for any website is kept in database in the forms of tables.
Table is the collection of related data entries and it consist of columns and rows.
A row of information is called tuple.

What is Query?
Query is a question or a request. With the help of query you can show, add,edit and delete any record.

How to create database?
Its very simple, just open your database, create database as below:
1)Open link http://localhost/phpmyadmin.
2)Click on the database tab.
3)Give name of database and create like below.

now  I will inside the database called test as below:
How to create tables?
1)Once you have created database, click on the database.
For example, I have created a database called test. So 



2) Create table on the database test.
3) Give table name and number of fields needed and click on create..
4) After that give the field names, data types and most important a primary key.
5) And also set your primary key to auto-increment as it will be auto-incremented as you add data from front-end.

Comments

Popular posts from this blog

MySQL Connection

Connection with MySQL Database Before accessing database, you must create a connection to the database Syntax: mysql_connect(servername,username,password); where, servername specifies the server to connect to. Default value is “localhost” username specifies the username to log in with. Default value is the name of the user that owns the server process. To connect offline we use username “root”. password specifies the password to log in with. Default is “” Code : Creating connection to the database and selecting the required database <?php $con = mysql_connect(“localhost”,”root”,”"); if (!$con) { die(‘Could not connect: ‘ . mysql_error()); } else{ mysql_select_db(“test”, $con) }; ?> Here, we have store connection in a variable called $con and trap error using die function. Closing connection The connection will be closed automatically when the script ends. To close the connection before, use the mysql_close() function: <?php $con = mysql_conne

Type Juggling and Type Casting

Type Juggling: PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which the variable is used. That is to say, if a string value is assigned to variable $var, $var becomes a string. If an integer value is then assigned to $var, it becomes an integer.

Doctype Defination

A Document Type Declaration, or DOCTYPE, is an instruction that associates a particular SGML or XML document (for example, a webpage) with a Document Type Definition (DTD). Syntax The general syntax for a document type declaration is: <!DOCTYPE root-element PUBLIC "FPI" ["URI"] [ <!-- internal subset declarations --> ]>