Web Programming

CSC 240
Union College
Fall 2009

News

Homework 6 is online.

Homework 5

Topic: PHP and MySQL
Due date: Thursday, October 22nd

Objectives

Create an application using PHP and MySQL that will accept user's votes for songs, tabulate them and produce a report of the current number of votes for all the songs.

Part 1

Create a table of songs in your MySQL database. Include fields for song title (key field), artist, and number of votes. Populate it with several songs to test it.

Part 2

Write a PHP page that gives the user the option of either voting for a song that is already in the database or entering (and thereby voting for) a new song. The form should have a selection list from which the user can choose an existing song and two text boxes for entering a new song - one for the title, and the other for the artist, The selection list should show all the songs (titles with artists) currently in the database in alphabetical order by title.

Part 3

Write the PHP page to record the user's vote and display a summary of the current vote count for all songs. If the user entered a new song in the text boxes on the data collection form, the script should add the new song to the table with a vote count of 1. Otherwise, the script should add to the vote count for the song selected from the list. The page should display a "Thanks for your vote" message with the song title the user entered and its current number of votes at the head of the page.

Add PHP code to produce a report (table) on the bottom of the page that lists all the songs in the database in order of popularity. To sort in descending order, add the keyword DESC after the sort field name (... ORDER BY sort_field DESC ...).

Part 4

Name and publish your PHP data collection page so that its URL is "http://antipasto.union.edu/~username/csc240/hw/hw5".

Turn in

Printouts of your two PHP pages.