Create table in phpMyAdmin

SAMPLE: A FEEDBACK SYSTEM


As a continuation to the last exercise, that is after creating the Database
Enter “Feedback” in the field below Create new table on the database BGdb” and enter “5” for the Number of fields and click the “Go” button.
See the screenshot below

more

Immediately this is done, you will see several form elements arranged as we have below, this is to enable you to setup the five (5) fields and their respective properties.  

fieldprop

Now let’s start with the first and probably the most important field, ID.

I fill the id space as we have below

more2

  • Field (id): this is the name of the field 
  • Type (INT): this will ensure that only whole number is permitted in this field
  • Length/Values (10): this set the number digit for this “id” field, 6 would be a million, therefore 10 is very large set of digits, isn’t it?   
  • Null (not null): this is important as it force the “id” field not to return a null value
  • Extra (auto_increment): this will enter auto generated number in this id field (in ascending order 1, 2, 3…) when we enter record into this table 
  • Primary key: this makes this “id” field to be the primary key.

Similarly I fill the other fields as we have in the screenshot below. These fields are name, email, comment and date_submit, while the properties I set for each of these are only Field, Type, Length/Values and Null

 

more3

When this is done, then click the “Save” button and the Feedback table will be created as we have below.

done

If you prefer to do this using an SQL statement, click the SQL tab,

sql2
And enter this SQL below, in the box before clicking the “Go” button.

CREATE TABLE Feedback (
id INT(10) NOT NULL AUTO_INCREMENT ,
name VARCHAR(255) NULL ,
email VARCHAR(255) NULL ,
comment TEXT NULL ,
date_submit DATETIME NULL ,
PRIMARY KEY (id)
);

To show this SQL example (below) I replace Feedback with Feedback2 so the name won’t conflict with the existing Feedback table.

sql3

Clicking the “Go” button the table would was created.

2

I knew using this SQL method could be little bit awkward to some new web developer, so let’s use this opportunity to learn how to delete this table. The technical term for this is “drop” so let’s drop the feedback2 table.

 

 

Next »


Return to PHP Sample Main Page