Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $response = array();
- require_once __DIR__ .'/db_connect.php';
- $db = new DB_CONNECT();
- $result = mysql_query("SELECT * FROM products");
- if (mysql_num_rows($result) > 0) {
- $response['product'] = array();
- while($row = mysql_fetch_array($result)) {
- $product = array();
- $product['pid'] = $row['pid'];
- $product['name'] = $row['name'];
- $product['price'] = $row['price'];
- $product['created_at'] = $row['created_at'];
- $product['updated_at'] = $row['updated_at'];
- array_push($response['products'], $product);
- }
- $response['success'] = 1;
- } else {
- $response['success'] = 0;
- $response['message'] = "No product found";
- }
- echo json_encode($response);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment