SHARE
TWEET

android-intermediate-day2-task7

ahsai001 Sep 10th, 2019 159 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $user = "root";
  3. $pass = "";
  4. $host = "localhost";
  5. $dbname = "neardeal";
  6.  
  7. $store_id = $_REQUEST['store_id'];
  8.  
  9. // Create connection
  10. $conn = new mysqli($host, $user, $pass, $dbname);
  11.  
  12. // Check connection
  13. if ($conn->connect_error) {
  14.     die("Connection failed: " . $conn->connect_error);
  15. }
  16.  
  17. //get data
  18. $sql = "SELECT * FROM product WHERE store_id={$store_id}";
  19.  
  20. //
  21. $result = $conn->query($sql);
  22. $products = array();
  23.  
  24. while($row = $result->fetch_assoc()) {
  25.     $products[] = $row;
  26. }
  27.  
  28. echo json_encode(array(
  29.     'success' => true,
  30.     'product' => $products
  31. ));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top