Final Exam for MySQL and PHP

CIS159

Spring 2022


This is an online open note/open book final exam - it is also an individual project. You may receive help ONLY from me. This exam is given using the honor system with my trust in you and my confidence that you will not betray that trust. Working with other people or asking questions of other people is a betrayal of that trust - it is cheating. Helping other people or answering their questions is also a betrayal of that trust - it is cheating. If you have any questions, e-mail me to clarify. The completed exam should be turned in via e-mail by misnight on the posted date. You must also turn in the status sheet that is posted at the site, it is part of the final and I will only correct the final if I have the status sheet. The final must be passed on the posted date or before. You should email me the exam and the status sheet. Email it to the regular address used in the class and also for good measure to p.grocer@rcn.com. Again, please remember that the status sheet is a requirement for the course and I will only correct exams for people who turn in the status sheet.

Problem #1: You need to write an update program that can add, change or delete the fields on a table. I am looking for effective maintenance and something easy for the user to work with. You need to be able to add a record to the table, change an existing record and delete a record. I suggest you use my update as a model to create one of your own with a different table. You can also decide to write one from scratch. If you do both, I will give you extra credit.

Problem #2: Write a program using PHP that prints the numbers from 1 to 100. But for multiples of three print "By 3" instead of the number and for the multiples of five print "By 5". For numbers which are multiples of both three and five print "By 3 and 5".

Problem #3: You need to write PHP programs to do the following: Create a database inventory table and a transaction table. The inventory table will have item number, item name, on hand and on order. Take in transactions from the user to update the on hand and on order. The transaction will contain the item number, the code and the amt. They will enter the item number, a code of S if something was sold and a code of R if something was received. Sales should be subtracted from on hand. Receipts should be added to on hand and subtracted from on order. Write the program(s) to create the table, populate the table and process Sales and Receipts.

Problem #4: Using the inventory table you created above develop the following queries within a program or programs: If you had problems with the table, write the code you would have used.

  1. Select all items where the on hand is between a range stored as variables.
  2. Select all items where the item number is greater than a variable number AND EITHER the on hand is greater than a variable number OR the on order is greater than a variable number.
  3. Do a select query that uses a subquery.
  4. Do a select query that extracts part of the data in a field.
EXTRA CREDIT: If you store the variables in a session and retrieve them for the queries you will get extra credit. You can pick up extra credit by using sessions.