File: /home/barbeatleanalyti/public_html/api.beatleanalytics.com/customer/get_product.php
<?php
/*
* Following code will get single department details
* A industry is identified by dept_id
*/
// array for JSON response
$response = array();
// include db connect class
require_once 'db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// get a details from beatle_products table
$result = mysql_query("SELECT * FROM beatle_products")or die(mysql_error());
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$response["productDetail"] = array();
while ($row = mysql_fetch_array($result)) {
$productDetail = array();
$productDetail["productid"] = $row["productid"];
$productDetail["name"] = $row["name"];
$productDetail["points"] = $row["points"];
$productDetail["stock"] = $row["stock"];
$productDetail["image"] = $row["prod_image"];
$productDetail["created_date"] = $row["created_date"];
$productDetail["updated_date"] = $row["updated_date"];
// push single product into final response array
array_push($response["productDetail"], $productDetail);
}
// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No product found";
// echo no users JSON
echo json_encode($response);
}
} else {
// no industry found
$response["success"] = 0;
$response["message"] = "No product found.";
// echo no users JSON
echo json_encode($response);
}
?>