<?php
$database = new SQLite3('./data/.bet_tmdb.db');
if (!$database) {
    die("Connection failed: " . $database->lastErrorMsg());
}
$sql = "SELECT * FROM ads";

$result = $database->query($sql);

$adverts = array();
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
    $adverts[] = array(
        "image" => $row["images"],
        "artWork" => "",
        "title" => $row["title"],
        "subtitle" => $row["description"],
        "url" => ""
    );
}
$database->close();
header("Content-Type: application/json");
echo json_encode($adverts);
?>
