本文整理汇总了PHP中product::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP product::fetch方法的具体用法?PHP product::fetch怎么用?PHP product::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product
的用法示例。
在下文中一共展示了product::fetch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_products
function get_products()
{
include_once 'product.php';
$obj = new product();
if (!$obj->connect()) {
$json = '{"status":2, "products":{}}';
echo $json;
exit;
}
if ($obj->get_products()) {
$row = $obj->fetch();
$length = $obj->get_num_rows();
// Products as a set
$json = '{"status":0, "products":{';
for ($i = 0; $i < $length; $i++) {
$bcode = $row['PRODUCT_BARCODE'];
$json = $json . '"' . $bcode . '":' . json_encode($row);
$row = $obj->fetch();
if ($i < $length - 1) {
$json = $json . ',';
}
}
$json = $json . '}}';
// Products as an array
// $json='{"status":0, "products":[';
// for($i=0; $i<$length; $i++){
//
// $bcode = $row['PRODUCT_BARCODE'];
// $json=$json.'{"'.$bcode.'":'.json_encode($row).'}';
// $row=$obj->fetch();
// if($i<$length-1){
// $json=$json.',';
// }
// }
// $json=$json.']}';
echo $json;
// $d = json_decode($json);
// print_r($d);
} else {
$json = '{"status":1, "products":{}}';
echo $json;
}
}
示例2: getStock
function getStock()
{
$message = $_REQUEST["message"];
$mess = explode(" ", $message);
$pnum = $_REQUEST["pnum"];
include "product.php";
$obj = new product();
if ($obj->displayProduct($mess[0])) {
$row = $obj->fetch();
$msg = $row['pname'] + "<br>" + $row['price'] + "<br>" + $row['qty'];
echo $msg;
// sms($msg,$pnum);
} else {
echo '{"result":0}';
}
}
示例3: utf8_encode
<?php
include "../classes/product.php";
$obj = new product();
$row = $obj->get_all_products();
$html = "";
while ($row) {
$html .= "<div id = 'home1' data-role = 'collapsible'>";
$html .= "<h1>{$row['name']}</h1>";
$html .= "<ul id = 'theList' data-role='listview'>";
$html .= "<li><a href='#'>Product Code: {$row['code']}</a></li>";
$html .= "<li><a href='#'>Product Name: {$row['name']}</a></li>";
$html .= "<li><a href='#'>Selling Price : GHC {$row['selling_price']}</a></li>";
$html .= "<li><a href='#'>Cost Price : GHC {$row['cost_price']}</a></li>";
$html .= "<li><a href='#'>Quantity in Stock : {$row['stock_level']}</a></li></ul>";
$html .= "</div>";
$row = $obj->fetch();
}
echo utf8_encode($html);
?>
示例4: product
<?php
include_once 'header.php';
include_once 'lib/product.php';
$ma = $_GET['ma'];
$product = new product();
$sql = "SELECT * FROM san_pham\n\t\tWHERE id_san_pham = {$ma}";
$product->query($sql);
$row = $product->fetch();
if (isset($_POST['btn-update'])) {
$product = new product();
$product->set_id_sp($ma);
$product->set_id_loai_sp($_POST['id_loai']);
$product->set_ten_sp($_POST['ten_sp']);
$product->set_gia_sp($_POST['gia_sp']);
$product->set_mo_ta($_POST['mo_ta']);
$product->set_trang_thai($_POST['trang_thai']);
echo $product->edit_sp();
header('location:products.php');
}
?>
<div class="clearfix"></div><br />
<div class="container">
<form method='post'>
<table class='table table-bordered'>
<tr>
<td><label for="id_loai" style="font-weight: normal;">ID loại sản phẩm</label></td>
示例5:
<div class="col-md-12">
<table class="table table-bordered table-responsive mytable">
<thead>
<tr>
<th>Mã sản phẩm</th>
<th>Mã loại</th>
<th>Tên sản phẩm</th>
<th>Giá sản phẩm</th>
<th>Mô tả</th>
<th>Trạng thái</th>
<th colspan="2" align="center"><center>Hành động</center></th>
</tr>
</thead>
<tbody>
<?php
while ($row = $product->fetch()) {
?>
<tr>
<td><?php
echo $row['id_san_pham'];
?>
</td>
<td><?php
echo $row['id_loai_sp'];
?>
</td>
<td style="text-align: left;"><?php
echo $row['ten_sp'];
?>
</td>
<td><?php
示例6: product_quantity
function product_quantity()
{
include_once 'product.php';
$name = $_GET['product_name'];
$obj = new product();
if (!$obj->connect()) {
$response = 'Not connected';
echo $response;
exit;
}
if ($obj->get_product_quantity($name)) {
$row = $obj->fetch();
$response = "Quantity of " . $name . " is " . $row['QUANTITY'];
echo $response;
} else {
$response = 'Not Found';
echo $response;
}
}