Assignment 4
CS451/551, Spring 2024
due Monday, May 13
In this assignment you are to write a PHP program which will perform
a simple query on the stores7 database. This program will
be invoked by an html form. The form will take as input the name of
a manufacturer (Anza, Hero, etc.).
The PHP in response should construct SQL to look at each of that
manufacturer's
orders and determine which customers have ordered something from them
(and what they ordered).
Output should include
- first and last name of the customer
- the description of that item, from the stock table
This will require a join of the
customer, orders, items, stock, and manufact tables.
Here
is a fairly simple example
In addition
- this should connect with your own instance of MySQL, running on ix (or ix-dev)
- use the mysqli php class (as in the example above)
- Rename your files to reflect the purpose of the script (not just findCust).
Extras
-
If you want to be fancy (not required), query the names of all manufacturers and
construct a drop down menu allowing the web page user to select the name. Thus
if a manufacturer were added or removed, the web page would reflect that change.
- Format the output a bit nicer.
- instead of using mysqli_real_escape_string, use a
prepared statement
(see also here)
To turn in this assignment,
include the URL as a comment in canvas.
- You may want to use the PDO interface, which is vendor independent, instead of mysqli.
Example here.
- You are welcome to use any other interface technique that is running on
department servers.
Quick primer on getting html and php files on ix
- In your home directory on the departmental machine ix you should
have a directory called public_html. Any .html or .php files
should be put in here.
- You can try copying the findCust.html file given as an example into your
public_html directory. You will be able to access it with the URL
http://ix.cs.uoregon.edu/~cwilson/findCust.html, where obviously you replace
cwilson with your own login (keep the tilde "~").
- You can download a copy of all files used in the example from the Canvas CS451/551
page under the files tab in "exampleHW4.zip".
- If you want to put it a subdirectory, for example public_html/asst4/,
then the URL becomes http://ix.cs.uoregon.edu/~cwilson/asst4/findCust.html.
-
Your .php files will go in the same location. Any file with the .php extension
will have its embedded code run as php.
-
If you want anyone to see the original php code, you should make a copy of it
as a .txt file so that the php will not be executed (graders like to see your
code).
-
The example code can be copied (from
here)
for you to modify. (Or zipped together as mentioned above.)
-
The example php will need the provided connection data to be placed in the
same directory. This provides a port number and login info.