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
<?php

if (!isset($_GET['p'])) {
    $page_array = load_page(0);
} else {
    $page_array = load_page($_GET['p']);
}
if (!$page_array == false) {
    echo "<h1> " . $page_array['page_name'] . "</h1><br/>";
    echo $page_array['content'];
} else {
    echo "<h1> We konden de pagina helaas niet vinden. Probeer het opnieuw.";
}

function load_page($load_page) {
    $db_handle = db_connection();
    /* Query the database for the page */
    $result = $db_handle->query("SELECT * FROM pages where ID = " . mysqli_real_escape_string($db_handle, $load_page) . ";");
    /* Only one page to be returned */
    $page_array = $result->fetch_array(MYSQLI_ASSOC);
    $db_handle->close();
    if ($result->num_rows == 1) {
        return $page_array;
    } else {
        return false;
    }
}

?>