Guest User

Untitled

a guest
May 27th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  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. ?>
Add Comment
Please, Sign In to add comment