I am doing the Harvards building dynamic websites called CS-75 (also could be called E-75), because someone told me about it and I just thought might as well, it is all learning 🙂 even if allot of it you may already know.
Anyway, to setup the CS75 on my personal laptop ( I am running Ubuntu 10.4) I did a couple of alternations for me so that the local apache instance looks like I am doing it under the top level domain of CS75 :).. so for this assignment Three Aces menu I am calling the website http://threeaces.cs75 on my local host, so to setup that I altered the /etc/hosts file and added
so that local IP will also have threeaces.cs75 🙂 and now need to alter apache to allow me to run that as a virtualhost on my laptop, I added the file within
sudo vim /etc/apache2/sites-available/cs75_threeaces
with adding in
Options Indexes FollowSymLinks MultiViews
allow from all
CustomLog /var/log/apache2/access.log combined
Which points to the /var/www/cs75/ass0 as the base directory for this assignment :).
I have included the assignments 0 PDF for more information, but basically this assignment is about playing with simpleXML to load in a menu (that you have created from the menu list of the restaurant Three Aces) which is in XML format, you get to pick the format, but here is mine (it has the extras link within the menu->type extras attribute which link to the extras at the bottom of the menu format)
You can implement it anyway that you want to, but to not have two same names of the food for different sizes. So that is why I have a the item name with the price list(s) underneath. It is only part of the menu that I implemented above.
The next part is to only have part of the menu on the main home page, so I am just displaying the main types of food options, I have included the source file for all of the files in the zip file above.
Because there is a basket of items that the customer will like to buy, I am also storing the basket details within the $_SESSION within a multi array, the array looks like something like
[Pizzas] => Array
[Tomato Cheese] => Array
[Small] => Array
[price] => 5.5
[quantity] => 6
So in the next page, checkout.php I need to update the basket details and also then display what the customer has already picked (with giving the options to update the quantity of goods and also to remove them if they did not want it), the first part loads the new item(s) into the basket and the second part of the code below will display the basket to the user, and call the update.php file if any quantities/remove of items need to be done.
here is the update.php, this will update the basket from the requested action from the above php file.
$key = str_replace("@", " ", $key);
list($type, $item, $size,$command) = split("_", $key);
if ($command== "quantity" && $value > 0)
$basket[$type][$item][$size]["quantity"] = $value;
elseif ($command =="remove")
// clean out the type -> item if none more left
// clean out the type if none left
$_SESSION["basket"] = $basket;
// redirect back to checkout.php
and redirects back to checkout.php.
The last page displays the order in total and also says thanks very much for the order :).. and deletes the basket details :).
foreach ($basket as $type => $typevalue)
foreach ($typevalue as $item => $itemvalue)
foreach ($itemvalue as $size => $sizevalue)
$totalPrice +=$sizevalue["price"] * $sizevalue["quantity"];
echo "||£".number_format($sizevalue["price"],2) . "||" . $sizevalue["quantity"] . "||£".number_format($sizevalue["price"] * $sizevalue["quantity"],2) ."|
echo "The total price is £".number_format($totalPrice,2)."
The file above does include all of the php files from the above comments and the PDF of the assignment. You can also view the assignment live on my CS – 75 assignment 0 test area.