data into MySql Database
Use PHPMyAdmin create Database
In the lessonWorking with forms, we collect
client's name and phone number and we plan to save this collected
information into database.
step, we need create a database in mysql.( Assume you already
installed mysql,php and phpMyAdmin.)
Launch your phpMyAdmin in browser by typing http://localhost/phpadmin/index.php(or
your setting URL).
On the right panel of phpMyAdmin, you will see
a part like the following images:
Input phonebook in "Create
new Database" box, click on create.
You will see "Database phonebook has been
in the updated panel and the following image:
Using phpMyAdmin Create table in Mysql database phonebook
table in phonebook. In the above image, input "contact" in
the "Create new table on database phonebook, name" box.
Since we need store 2 values, name and phonenumber, we
input 2 in number of fields. Then Click on "GO". You
will the following updated window:(click on it to see the detail).
Input "name" in the first field, choose "VARCHAR" for type. (varchar
means "name" are strings with different length). Check the
radio button under that "Key" images. This means "name" is
the primary key for this table, no records with same name
are allowed in this table.
Input "phonenumber" in the second filed, choose "Varchar" for type.
Then click on "save" Button. You will see "Table
contact has been created." message on the updated
window and the following image:
You may used the above panel to change/update your table setting.
use command line to create database and table
Open a DOS console window, go to c:\mysql\bin.
Type: mysql -u root -p , press enter;
You will see prompt: Enter password:, now
enter your password. You will see prompt mysql>
Type: the following command
CREATE DATABASE `phonebook` ;
`contact` ( `name` VARCHAR( 50 )
NOT NULL ,
`phonenumber` VARCHAR( 20 ) NOT NULL ,
PRIMARY KEY ( `name` ))
TYPE = MYISAM ;
You will get the same result of using PhpMyAdmin.