PHP How to Create Table


 

PHP How to Create Table

PHP How to Create Table: In this PHP tutorial you will get to know about how to create table using WAMP server and MySQL console.

PHP How to Create Table: In this PHP tutorial you will get to know about how to create table using WAMP server and MySQL console.

PHP Create Table:

In every database we need to create table, tables are the collection of rows and columns, column store one specific type of data, and rows are the collection of columns. Suppose that we want to store data about employee, column represents the attributes of employee: emp_name, emp_code, salary etc. Now if we combine these attributes in a meaningful manner then we can get the record of a particular employee, that collection of an employee is represented by a row.

To create a table we need to create a database first and then open it. (To know how to create and open a database please visit our web page: http://roseindia.net/tutorial/php/phpdatabase/PHP-Create-Database.html )

After opening the database we can create table by one of the  following way:

$)    Using MySQL Console:

        i)    Start the WAMP server, after that open MySQL console. Open any previously created database, after that write as follows:

 

In the above code create table are commands and  student is the name of the table. s_name, age, address are the fieldnames. varchar and integer are the datatypes and 10 is the size of the field (In next tutorials we will study all datatypes of MySQL in details)

$)    Using WAMP server:

Start  the  WAMP server, after that open http://localhost/phpMyAdmin page (details are available on http://roseindia.net/tutorial/php/phpdatabase/PHP-Create-Database.html)

i)    First of all open the WAMP server and select Database tab:

ii)    After that, next page will show you the list of the databases, select any database:

iii)    After selecting any database, in the next page fill the textbox with a proper name of the table and choose the number of fields:

iv) After doing that next page will show you a form like page which will be the details of the table's field, fill it with appropriate type, length ( rest of the fields will be discussed later) :

v) After filling the form click on save button. Next page will show you the data dictionary of the table, as follows:

 

Ads