<html>
<head>
<title>Project 1 - Ryan Small</title>
</head>
<body>
<pre>
<?php
extract($_REQUEST, EXTR_SKIP); //extracting the form input
// $days is the variable that contains the amount of days to count for as received from project1.htm
$i = 1;
$j = 1;
$total = 0; // deals with calculating the price of what day you're trying to figure out the cost for
$totaltwelve = 0; // deals with calculting the price for the twelve days individually
$totalday = 0; // deals with calculating the price of all twelve days
$gifts = array( " ", "Partridge in a pear tree", "Turtle Doves", "French Hens", "Calling Bird",
"Gold Rings", "Geese-a-Laying", "Swans-a-Swimming", "Maid-a-Milking", "Lady Dancing",
"Lords-a-Leaping", "Pipers Piping", "Drummers Drumming");
$giftPrices = array( 0, 104.99, 20.00, 15.00, 99.99, 65.00, 50.00, 600.00, 5.15, 508.46, 403.91, 186.65, 185.36);
echo "<br>";
echo "There are " . $days . " days to display for the christmas song.";
echo "<br /><br />";
echo "The gifts for day " . $days . " are:";
echo "</br>";
while ($i <= $days)
{
echo $i . " " . $gifts[$i] . " " . "\$" . number_format( ( $giftPrices[$i] * $i ), 2 ) . "<br />";
$total += ( $giftPrices[$i] * $i );
$i++;
}
echo "<br />";
echo "The total cost for " . $days . " days is: " . "\$" . number_format( $total, 2 );
echo "<br />";
while ( $j <= 12 )
{
$totalday += ( $giftPrices[$j] * $j );
$totaltwelve += $totalday;
$j++;
}
echo "<br />";
echo "The total cost for 12 days is \$" . number_format( $totaltwelve, 2);
?>
</pre>
</body>
</html>