-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
35 lines (25 loc) · 889 Bytes
/
index.php
File metadata and controls
35 lines (25 loc) · 889 Bytes
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
32
33
34
35
<?php # index.php - Script 9.7
// Need the utilities file:
require('includes/utilities.inc.php');
// Include the header:
$pageTitle = 'Welcome to the Site!';
include('includes/header.inc.php');
// Fetch the three most recent pages:
try {
$q = 'SELECT id, title, content, dateAdded FROM pages ORDER BY dateAdded DESC LIMIT 3';
$r = $pdo->query($q);
// Check that rows were returned:
if ($r && $r->rowCount() > 0) {
// Set the fetch mode:
$r->setFetchMode(PDO::FETCH_CLASS, 'Page');
// Records will be fetched in the view:
include('views/index.html');
} else { // Problem!
throw new Exception('No content is available to be viewed at this time.');
}
} catch (Exception $e) { // Catch generic Exceptions.
include('views/error.html');
}
// Include the footer:
include('includes/footer.inc.php');
?>