<?php require 'connection.php'; require 'shop_classes.php'; if (!isset($shop)) { $shop = new Shop(); $cart = new ShoppingCart(); } $query = "SELECT * FROM items;"; $result = mysqli_query($link, $query); $index = 0; $resultsArray = []; while ($row = mysqli_fetch_assoc($result)) { $resultsArray[$index] = $row; $index++; } foreach ($resultsArray as $item) { $shop->addItem(new Item($item['id'], $item['name'], $item['description'], $item['price'])); }
} $file = $Shop->getShop($shop); if($file == false || $file == null) { $errors[] = "No shop with the name {$shop} was found."; } if(count($errors) < 1) { $data = explode(":", $item); $item = new Shop_Item($data[0], $data[1]); $item->setBuy($buyprice, $bundlebuy); $item->setSell($sellprice, $bundlesell); $item->setStock(0, $stock); if($Shop->addItem($item)) { $success = "<strong>Added item</strong> ".$items->getName($data[0] . ':' . $data[1])." to <strong>{$shop}</strong> - <a href='editor.php?edit={$shop}'>view changes</a> or add another:<br />"; } else { $errors[] = "Could not add item to {$shop} check to make sure the file is writable!"; } } } if(count($errors) > 0): echo '<p><strong>There was an error processing the form.</strong></p>'; echo '<ul>'; foreach($errors as $error): echo "<li>$error</li>"; endforeach;