CSCI 2006 - Spring 2024 - Server-Side ProgrammingAssignment #2 - Shopping Site and Cart Modification

Assignment #2 - Shopping Site and Cart Modification

Purpose: Expand our webpage to include additional features

Instructions

  1. You will be constructing this website. Please view and copy the HTML source for this assignment, you will still have to build PHP that delivers this content based on the requirements, but you are not responsible for designing HTML and CSS for this assignment
  2. You will be getting the data for this website from a database. The account database information is:
    DATABASE: csci2006_artShop
    USERNAME: csci2006_art
    PASSWORD: hz0fs9vV4vkKL4An
  3. You will need several queries in order to gather all of the necessary data. The following is meant to provide you with the SQL and information on what is reported back from each query. For all queries that require an input, you should utilize an input sanitation method demonstrated in lab #7
    1. SELECT * FROM Artist WHERE artist_id=?
      This query requires one parameter, an integer representing the artist's id
      /* Sample Results (sample is of a single row) */
      array(
      	"artist_id"=>1,
      	"artist_name"=>"Johannes Vermeer",
      	"artist_birth"=>1632,
      	"artist_death"=>1675,
      )
    2. SELECT * FROM Work WHERE work_id=?
      This query requires one parameter, an integer representing the artwork's id
      /* Sample Results (sample is of a single row) */
      array(
      	"work_id"=>1,
      	"work_artist"=>1, /* this is the artist's id */
      	"work_name"=>"Girl with a Pearl Earring",
      	"work_created"=>1665,
      	/* Note that there are not any paragraphs of description text here */
      )
    3. SELECT * FROM Description WHERE desc_work=? ORDER BY desc_ord ASC
      This query requires one parameter, an integer representing the artwork's id
      /* Sample Results (sample is of a single row) */
      array(
      	"desc_work"=>1, /* This is the artwork's id */
      	"desc_ord"=>1, /* This is an integer to represent the order the paragraphs should appear. The query should return them to you sorted */
      	"desc_text"=>"The painting is a tronie, the Dutch 17th-century..."
      	/* Note, these paragraphs do not contain HTML, you will need to add the <p> tags */
      )
    4. SELECT * FROM Variation WHERE variation_work=?
      This query requires one parameter, an integer representing the artwork's id
      /* Sample Results (sample is of a single row) */
      array(
      	"variation_id"=>1,
      	"variation_work"=>1, /* This is the artwork's id */
      	"variation_name"=>"4x5 Reprint",
      	"variation_price"=>28,
      )
    5. SELECT * FROM Work
       INNER JOIN Artist on artist_id=work_artist
      This query does not require any parameters
      /* Sample Results (sample is of a single row) */
      array(
      	"work_id"=>1,
      	"work_artist"=>1,
      	"work_name"=>"Girl with a Pearl Earring",
      	"work_created"=>1665,
      	"artist_id"=>1,
      	"artist_name"=>"Johannes Vermeer",
      	"artist_birth"=>1632,
      	"artist_death"=>1675,
      )
    6. SELECT * FROM Cart WHERE cart_id=?
      This query requires one parameter, an integer representing the cart's id
      /* Sample Results (sample is of a single row) */
      array(
      	"cart_id"=>5,
      	"cart_user"=>1,
      	"cart_status"=>"open",
      	"cart_closedTotal"=>0,
      	"cart_created"=>"2024-02-01",
      )
    7. SELECT * FROM CartItem
       INNER JOIN Variation ON variation_id=ci_variation
       INNER JOIN Work ON work_id=variation_work
       WHERE ci_cart=?
      This query requires one parameter, an integer representing the cart's id
      /* Sample Results (sample is of a single row) */
      array(
      	"ci_cart"=>5, /* this is the cart's id */
      	"ci_variation"=>39,
      	"ci_qty"=>2, /* the quantity of this variation in the cart */
      	"variation_id"=>39, 
      	"variation_name"=>"8x10 Reprint",
      	"variation_price"=>76,
      	"work_id"=>8,
      	"work_artist"=>2,
      	"work_name"=>"Young Hare",
      	"work_created"=>1502,
      )
  4. Note that there are 3 page templates: home page, artwork page, and cart page. Each of these will require use of different queries and different amounts of processing work in the PHP to present the data from the database to the user. You may use any approach to processing the data (for example, my solution uses a class approach to encapsulate each type of data so that they can have different processing methods defined for them)
  5. Note that you can change which cart you are looking at in the example cart by adding "&cart=5" or "&cart=7" to the end of the query string. Please implement this concept into your website as well
  6. Compare your website's totals to the example website's to ensure that your cart calculations are the same. The logic for those calculations should be the same as Assignment #1
  7. Upload your files to the a folder called "assignment2", inside your csci2006 folder
  8. In a web-browser, go to the URL below to verify it appears as expected
  9. Ensure that your code is not producing any errors or warnings, by using the log-access tool. If you have trouble understanding the log messages, please email me for assistance. Note the log does not reset, so you need to look at when any errors/warnings occurred and which HTTP request they were for to better understand whether you have already fixed that issue

Submitting Instructions