Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //--------------------------------------------------------------------------
- // Example php script for fetching data from mysql database
- //--------------------------------------------------------------------------
- $host = "localhost";
- $user = "username";
- $pass = "********";
- $databaseName = "malikent_umchiphop";
- $tableName = "videos";
- //--------------------------------------------------------------------------
- // 1) Connect to mysql database
- //--------------------------------------------------------------------------
- include 'DB.php';
- $con = mysql_connect($host,$user,$pass);
- $dbs = mysql_select_db($databaseName, $con);
- //--------------------------------------------------------------------------
- // 2) Query database for data
- //--------------------------------------------------------------------------
- $result = mysql_query("SELECT * FROM $tableName"); //query
- $array = mysql_fetch_row($result); //fetch result
- //--------------------------------------------------------------------------
- // 3) echo result as json
- //--------------------------------------------------------------------------
- echo json_encode($array);
- ?>
Add Comment
Please, Sign In to add comment