SHARE
TWEET

Untitled

a guest May 27th, 2018 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.   //--------------------------------------------------------------------------
  4.   // Example php script for fetching data from mysql database
  5.   //--------------------------------------------------------------------------
  6.   $host = "localhost";
  7.   $user = "username";
  8.   $pass = "********";
  9.  
  10.   $databaseName = "malikent_umchiphop";
  11.   $tableName = "videos";
  12.  
  13.   //--------------------------------------------------------------------------
  14.   // 1) Connect to mysql database
  15.   //--------------------------------------------------------------------------
  16.   include 'DB.php';
  17.   $con = mysql_connect($host,$user,$pass);
  18.   $dbs = mysql_select_db($databaseName, $con);
  19.  
  20.   //--------------------------------------------------------------------------
  21.   // 2) Query database for data
  22.   //--------------------------------------------------------------------------
  23.   $result = mysql_query("SELECT * FROM $tableName");          //query
  24.   $array = mysql_fetch_row($result);                          //fetch result    
  25.  
  26.   //--------------------------------------------------------------------------
  27.   // 3) echo result as json
  28.   //--------------------------------------------------------------------------
  29.   echo json_encode($array);
  30.  
  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
 
Top