SHARE
TWEET

Untitled

a guest May 22nd, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- Connect to database -->
  2.     <?php
  3.         $dbhost = "localhost";
  4.         $dbuser = "root";
  5.         $dbpass = "";
  6.         $dbname = "lobster";
  7.  
  8.         $db = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
  9.  
  10.         if(mysqli_connect_errno()) {
  11.             die("Database connection failed: " .
  12.                 mysqli_connect_error() .
  13.                 " (" . mysqli_connect_errno() . ")"
  14.                 );
  15.         }
  16.  
  17.     ?>
  18.  
  19. <!-- Perform database query -->
  20.  
  21.     <?php
  22.         $query = "SELECT * FROM me_business";
  23.         $result = mysqli_query($db, $query);
  24.         // Test for query error
  25.         if (!$result) {
  26.             die("failure!");
  27.         }
  28.     ?>
  29.  
  30. <!-- Output Data -->
  31.    
  32.     <?php
  33.     while($row = mysqli_fetch_assoc($result)) {
  34.         $businiess_JSON = json_encode($row);
  35.         echo $businiess_JSON;
  36.     }
  37.     ?>
  38.  
  39. <!-- Release Data & Close connection to database -->
  40.     <?php
  41.  
  42.     mysqli_free_result($result);
  43.     mysqli_close($db);
  44.  
  45.     ?>
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
 
Top