HomeMediacenter/php/db/getmoviefromdb.php
2020-05-16 20:41:32 +02:00

37 lines
758 B
PHP
Executable File

<?php
$server = "172.17.0.2";
$user = "mediacenter";
$password = "w3xSBWWqvBFaLzmC";
$database = "mediacenter";
$data = new class{};
$link = new mysqli($server, $user, $password,$database);
if(mysqli_connect_errno())
{
echo "connecton failed... nr: ". mysqli_connect_errno(). " -- " . mysqli_connect_error();
}
if (isset($_POST['action'])) {
$action = $_POST['action'];
if ($action == "all") {
$query = "SELECT * FROM `movies`";
$result = mysqli_query($link,$query);
$resultnumber = $result->num_rows;
$data->data = array();
while($row = $result->fetch_assoc()) {
array_push($data->data, array('name' => $row['name'],'url' => $row['URL'],'thumbnail' => $row['thumbnail'] ));
}
}
}
echo(json_encode($data));
?>