Web Programming ct214H Lab3 php1
Web Programming ct214H Lab3 php1
v Hints:
1) Start XAMPP (find its icon from the desktop or Start menu):
Ex 2. Create DB in MySQL
v Objective: Using DDL to create DB in MySQL
Genres
mysql> (theloai):
+-----------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+-------+
| ma_tloai | int(10) unsigned | NO | PRI | NULL | |
| ten_tloai | varchar(30) | NO | | NULL | |
+-----------+------------------+------+-----+---------+-------+
2 rows in set (0.37 sec)
Reviews
mysql> (baiviet):
+----------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+-------+
| ma_bviet | int(10) unsigned | NO | PRI | NULL | |
| tieude | varchar(200) | NO | | NULL | |
| ten_bhat | varchar(100) | NO | | NULL | |
| ma_tloai | int(10) unsigned | NO | | NULL | |
| tomtat | varchar(500) | NO | | NULL | |
| baiviet | varchar(2000) | YES | | NULL | |
| ma_tgia | int(10) unsigned | NO | | NULL | |
| ngayviet | date | NO | | NULL | |
| image | longblob | YES | | NULL | |
+----------+------------------+------+-----+---------+-------+
9 rows in set (0.04 sec)
v Hints:
1) Connect to MySQL using the root account, and create a database using the
CREATE DATABASE command.
2) Create tables:
• Choose the database MUSIC (use the USE … command)
• Create tables using the CREATE TABLE command.
3) Add data to the tables:
a. Download the supported files and write the INSERT INTO command
with the downloaded data
b. Save the command to a file with a .sql extension.
Web Programming Fundamentals Labs (CT214H) – TS. Trần Công Án -32-
c. Use the command: source <tên tập tin .sql> t execute all
INSERT INTO in the sql file to add data to the tables.
d. Check the result using the SELECT * FROM … command.
v Requirement:
Ex 6. (Extra) Improve the Ex 5 to allow users use the double quote in the search
keyword, e.g. “lòng mẹ”, “yêu thương”,…
Ex 7. (Extra) Improve Ex 4 so the review summary doesn’t break the last word. If the
50th character is not a space, move to the previous or next space to cut the summary
(see Figure 23 and compare to Figure 22 to figure out the requirement).
Web Programming Fundamentals Labs (CT214H) – TS. Trần Công Án -35-
Figure 23. List of song reviews - Advanced