Skip to content
Snippets Groups Projects
Commit 83d242d4 authored by Omar Ibrahim Arfa's avatar Omar Ibrahim Arfa
Browse files

Implement PizzaObject into shop.php

parent dac89ad2
No related branches found
No related tags found
No related merge requests found
......@@ -16,8 +16,8 @@ declare(strict_types=1);
* @version 3.1
*/
// to do: change name 'shop' throughout this file
require_once './Page.php';
require_once './PizzaObject.php';
/**
* This is a template for top level classes, which represent
......@@ -69,14 +69,9 @@ class Shop extends Page
while ($row = $resultSet->fetch_assoc()) {
$pizza = array(
"article_id" => $row["article_id"],
"name" => $row["name"],
"picture" => $row["picture"],
"price" => $row["price"]
);
$pizza = new PizzaObject((int)$row["article_id"], $row["name"], $row["picture"], (float)$row["price"]);
$pizzaList[] = $pizza;
$pizzaList[$pizza->getName()] = $pizza;
}
$resultSet->free_result();
return $pizzaList;
......@@ -107,10 +102,10 @@ class Shop extends Page
foreach ($data as $pizza) {
echo <<< HTML
<label>
<img alt="Image of Pizza {$pizza["name"]}" src="{$pizza["picture"]}">
<img alt="Image of Pizza {$pizza->getName()}" src="{$pizza->getPicture()}">
<br>
{$pizza["name"]}<br>
{$pizza["price"]}
{$pizza->getName()}<br>
{$pizza->getPrice()}
</label>
<br>
HTML;
......@@ -130,7 +125,7 @@ class Shop extends Page
foreach ($data as $pizza) {
echo <<< HTML
<option value="{$pizza["name"]}">{$pizza["name"]}</option>
<option value="{$pizza->getArticleId()}">{$pizza->getName()}</option>
HTML;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment