MySQL Practice: Creating a PHP Script for Managing Courses in a MySQL Database - Prof. Fra, Assignments of Computer Science

An assignment for creating a php script named 'courses.php' to manage courses in a mysql database. The script should allow users to input new course information, save it to the database, and display a listing of all courses. The user should be able to insert new courses by clicking a link that brings them back to the 'courses.php' script. The script should also handle empty forms and duplicate course ids.

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-im8
koofers-user-im8 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MySQL Practice: Courses
Comp 250 - Internet Development
10 points
The purpose of this assignment is to give you practice using MySQL commands in a PHP script. You are to write a single PHP
script called courses.php that will initially ask the user to enter new information for a course. The screen should look
something like the left side of Figure 1.
Figure 1: Inputting a new course (left) and listing of all courses (right).
The user will complete the form and press the Sa ve button which will submit the form data back to courses.php. When the
form data is received, your script should first save the submitted data to the courses table in your database. Your SQL insert
statement will look like this if the data above had been submitted:
INSERT INTO courses VALUES (111, 'COMP', 101, 'Intro to Computing', 'Steil')
After inserting the data, you will display a listing of all the courses in the courses table using a SELECT statement that orders
the rows by department and course number:
SELECT * FROM courses ORDER BY dept, num
The screen should look similar to the right side of Figure 1. Make sure you include a link to insert more courses which just
links back to courses.php.
You will find it helpful to architect your script like this:
If REQUEST_METHOD == “GET” then
Display course input form
Else
Connect to the database
Insert submitted form data into database
Select all rows from the database
Display the table
End if
Make sure your script reacts appropriately if an empty form is submitted (don’t insert) or if a duplicate course ID is given
(check the number of inserts made after executing the INSERT statement).
Submit your completed courses.php to Easel, and make sure it is located in your public_html folder on Taz. Do not modify
your php file after the due date because the file’s timestamp will be used to ascertain when it was completed.

Partial preview of the text

Download MySQL Practice: Creating a PHP Script for Managing Courses in a MySQL Database - Prof. Fra and more Assignments Computer Science in PDF only on Docsity!

MySQL Practice: Courses Comp 250 - Internet Development 10 points

The purpose of this assignment is to give you practice using MySQL commands in a PHP script. You are to write a single PHP script called courses.php that will initially ask the user to enter new information for a course. The screen should look something like the left side of Figure 1.

Figure 1: Inputting a new course (left) and listing of all courses (right).

The user will complete the form and press the Save button which will submit the form data back to courses.php. When the form data is received, your script should first save the submitted data to the courses table in your database. Your SQL insert statement will look like this if the data above had been submitted:

INSERT INTO courses VALUES (111, 'COMP', 101, 'Intro to Computing', 'Steil')

After inserting the data, you will display a listing of all the courses in the courses table using a SELECT statement that orders the rows by department and course number:

SELECT * FROM courses ORDER BY dept, num

The screen should look similar to the right side of Figure 1. Make sure you include a link to insert more courses which just links back to courses.php.

You will find it helpful to architect your script like this:

If REQUEST_METHOD == “GET” then Display course input form Else Connect to the database Insert submitted form data into database Select all rows from the database Display the table End if

Make sure your script reacts appropriately if an empty form is submitted (don’t insert) or if a duplicate course ID is given (check the number of inserts made after executing the INSERT statement).

Submit your completed courses.php to Easel, and make sure it is located in your public_html folder on Taz. Do not modify your php file after the due date because the file’s timestamp will be used to ascertain when it was completed.