Bläddra i källkod

call db in '/' path, fetch first query result

blog-db
DESKTOP-Q2SHMM6\ernes 2 år sedan
förälder
incheckning
877533b117
1 ändrade filer med 7 tillägg och 1 borttagningar
  1. 7
    1
      public/index.php

+ 7
- 1
public/index.php Visa fil

@@ -36,7 +36,8 @@ function addFooter($response)
}

function init()
{
{

$art1 = ["slug" => "artikel-1", "title" => "Dit is titel 1", "content" => "Lorem ipsum 1"];
$art2 = ["slug" => "artikel-2", "title" => "Dit is titel 2", "content" => "Lorem ipsum 2"];
$art3 = ["slug" => "artikel-3", "title" => "Dit is titel 3", "content" => "Lorem ipsum 3"];
@@ -46,6 +47,11 @@ function init()


$app->get('/', function (Request $request, Response $response, array $args) {
global $db;
$sql = "SELECT * FROM blogs";
$ret = $db->query($sql);
$blogArray = $ret->fetchArray(SQLITE3_ASSOC);
if (!isset($_SESSION['blogs'])) {
init();
}

Laddar…
Avbryt
Spara