Assignment 3: PHP Solution

$30.00 $26.40

Description

There are two projects in this assignment. Follow the instructions for each project to complete them. You have been provided with the necessary files to complete these projects.

Project 1: CRM Admin

Overview

Demonstrate your ability to work with PHP by converting project1.html into a PHP file that looks similar to that shown in Figure 1.

Instructions

  1. You have been provided with an HTML file (project1.html) that includes all the necessary markup. Save this file as project1.php.
  2. Move the header and the <div> for the left navigation area into two separate include files named header.inc.php and left.inc.php. Use the PHP include() function to include each of these files back into the original file.
  3. Examine and then include the provided data.inc.php file. This file contains PHP variables that you will use below.
  4. Use a for loop to output the list in the My Orders area (see Figure 1 ).
  5. Create a function called outputOrderRow() that has the following signature:

function outputOrderRow($file, $title, $quantity, $price) { }

  1. Implement the body of the outputOrderRow() function. It should echo the passed information as a table row. Use the number_format() function to format the currency values with two decimal places. Calculate the value for the amount column.
  2. Replace the four cart table rows in the original with the following calls:

outputOrderRow($file1, $product1, $quantity1, $price1);

outputOrderRow($file2, $product2, $quantity2, $price2);

  1. Calculate the subtotal, shipping, and grand total using PHP. Replace the hard-coded values with your variables that contain the calculations. The shipping value will be $200 unless the subtotal is above $10,000, in which case it will be $100.

Test

Test the page in the browser (Remember that you cannot simply open a local PHP page in the browser using its open command. Instead you must have the browser request the page from a server. If you are using a local server such as XAMMP, the file must exist within the htdocs folder of the server, and then the request will be localhost/some-path/project1.php.). Verify that the calculations work appropriately by changing the values in the data.inc.php file.

lu2020wh9shw tmp cd5ad0a9940b6c0c

Figure 1 Completed Project 1

Project 2: Share Your Travel Photos

Overview

You have been provided with two files: a page that will eventually contain thumbnails for a variety of travel images (list.php) and a page that will eventually display the details of a single travel image (detail.php). Clicking a thumbnail in the first file will take you to the second page where you will be able to see details for that image, as shown in Figure 2 .

Instructions

  1. Both pages will make use of arrays that are contained within the include file travel-data.inc.php. Include this file in both pages.
  2. Both pages display a list of countries. Replace the hard-coded lists by looping through the $countries array to display a list (in details.php, the list is contained within the include file left.inc.php). Be sure to first use a PHP sort function. Each country in the list should be a link to list.php with the country name as a query string parameter. Also replace the continents hard-coded list with a loop as well.
  3. In list.php, replace the existing image list markup with a loop that displays the thumbnail image and link for each of the elements within the $images array (which is provided within travel-data.inc.php). Notice that the links are to detail.php and that they pass the id element as a query string parameter.
  4. After testing list.php to verify it works as expected, add logic to handle the country links. Each link in the country list should be to list.php but with the country name as a query string (e.g., list.php?country=Canada). You will need to filter the images list so that the page displays only those images from the specified country.
  5. In detail.php, retrieve the passed id in the query string, and use it as an index into the $images array. With that index, you can output the relevant title, image (in the images/travel/medium folder), user name, country, city, description, and tags.

Test

Test the pages in the browser. (Remember that you cannot simply open a local PHP page in the browser using its open command. Instead you must have the browser request the page from a server.)

lu2020wh9shw tmp 913904257f0c473

Figure 2.1 Completed Project 2

Submitting

Put your assignment in a folder named assign3_yourname (e.g., assign3_johnsmith). Put all resources used by your assignment into this folder and compress them into a zip file. Upload the assign3_yourname.zip file to the Assignment 3 submission folder under dropbox on elearning.