-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-video.php
33 lines (26 loc) · 886 Bytes
/
load-video.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
//header('Content-Type: application/json');
//Create Database connection
$db = mysql_connect("localhost","username","password");
if (!$db) {
die('Could not connect to db: ' . mysql_error());
}
//Select the Database
mysql_select_db(YOUR_DB_HERE,$db);
$rows = array();
//Replace * in the query with the column names.
$result = mysql_query("select * from Video ORDER BY `TABLE_NAME_HERE`.`id` DESC", $db);
//Create an array
$json_response = array();
while ($row = mysql_fetch_array($result)) {
$rows[] = $row;
// $json_response['data'] = $row_array;
//push the values in the array
// array_push($json_response,$row_array);
}
$json_response = array('data' => $rows);
// }
echo json_encode($json_response);
//Close the database connection
fclose($db);
?>