當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Shop::addItem方法代碼示例

本文整理匯總了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']));
}
開發者ID:stephenoreilly,項目名稱:smartydemo,代碼行數:19,代碼來源:initialize_shop.php

示例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;
    
開發者ID:nijikokun,項目名稱:ls_editsuite,代碼行數:30,代碼來源:add-item.php


注:本文中的Shop::addItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。