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; } }
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}'; } }
<?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); ?>
<?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>
<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
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; } }