本文整理汇总了PHP中Shop::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::addItem方法的具体用法?PHP Shop::addItem怎么用?PHP Shop::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::addItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Shop
<?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']));
}
示例2: explode
}
$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;