Professional Documents
Culture Documents
Web Programming ct214H Lab5 php3
Web Programming ct214H Lab5 php3
Objective: Combine the results in the previous labs to create a complete Song
Review website similar to the following figure.
Note:
• The exercises in this lab are based on the following exercises: Ex 3, Lab 2; Ex
7 (or Ex 4), Lab 3; Ex 5 (or Ex 6), Lab 3;
• Suppose that the HTML files of this website are saved in the folder
/htdocs/buoi5.
v Hint:
• Use the ALTER TABLE ADD COLUMN… statement.
• You can download any images for the reviews, or you can download them at
this link: http://bit.ly/1jD2deL
• Create folder buoi5/images and copy the downloaded images into this
folder.
• Use the UPDATE statement to update the name of the image file that will be
used for each review.
Note: To do this task more efficiently, we should name the image files using the
naming rule bviet_xx with xx as the id of the review (from 1 to 17, accordingly
to the provided data). After that, we can write one UPDATE statement for
assigning the image name for all reviews as follow:
v Requirement:
1) Create a homepage as shown in Figure 31 (music-home.php). This page will
show the 5 newest reviews with a format similar to Ex 3, Lab 2.
2) Modify the page menu so that the Home item links to the music-home.php.
v Hint:
1) Do the following steps:
• Copy the MusicTemplate file into music-home.php.
• Copy the code for generating the review list in Ex 4, Lab 3 into the place
that will show the content of the homepage (line 20).
• Modify the query to return only 5 newest reviews: use the ORDER BY
ngayviet DESC to sort the reviews by review date and LIMIT 5 to
eliminate the number of reviews.
Web Programming Fundamentals Labs (CT214H) – TS. Trần Công Án -49-
• Modify the PHP statement that generates the review information so each
review will be put in a div entry. HTML code for each entry (in Ex 3) is as
follows:
The PHP code for generating the review entries with the above structure
is as follows (pay attention to the corresponding between lines 1-7 of the
above code and lines 5-11 of the below code):
2) Do it by yourself.
Ex 4. Design the song review search page based on the review title.
v Objective: Design the song review search page based on the template page and
the result of Ex 5 (or Ex 6), Lab 2.
v Requirement:
1) Create a sing review search page based on the review title, similar to Figure
32 (music-search.php).
2) The search result includes the title (1st line), review date, author (2nd line),
song name, genre, and summary (3rd paragraph). The summary display only
the first 150 characters. The margin for each review entry is 30pt 10pt 20pt
30pt;
3) Update the Search item in the menu to the link page music-search.php.
4) Note: all formats must be done using CSS.
v Hint:
1) Similar to Ex 3, this exercise is based on the template page and the result of
the previous exercises: Ex 5 or Ex 6, Lab 3.
• Create a new file, “music-search.php” from the template file for this
exercise.
• Create a div to contain the search result and the search form. Put this div
inside the content part of the page (line 20).
• Copy the code for searching song reviews from the previous exercises
(including HTML code and PHP code) to the above div.
• Create a CSS file and create a structure for the div containing the search
result as follow:
Note: Lines 4-6 are used to cut 150 characters for the review summary,
which can avoid breaking the last word. This code doesn’t handle the case
in which the review is less than 150 characters.
2) Create CSS rules for the search result (the div s_entry and its inner divs): do
it yourself.
Ex 5. (Extra) Create pagination for the search page music-search.php so that each
page displays at most 5 results.
Ex 6. (Extra) Create pages for adding/deleting reviews based on the template and the
Lab 4 results. Update the website menu to link to the new pages.
Ex 7. (Extra) Design a webpage for updated song reviews using AJAX.
v Objective: Using AJAX to create asynchronous communication to the web server.