/
index.php
38 lines (28 loc) · 901 Bytes
/
index.php
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
36
37
38
<?php
try {
require "../configs/config.php";
require "./common.php";
$connection = new PDO($dsn, $username, $password, $options);
$sql = "SELECT * FROM tasks";
$statement = $connection->prepare($sql);
$statement->execute();
$result = $statement->fetchAll();
} catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
?>
<?php require("./templates/header.php"); ?>
<div class="container">
<?php
require("./templates/nav.php");
if (!$result && $statement->rowCount() == 0) { ?>
<h4> No tasks to display. Add one above.</h4>
<?php }
else
{
foreach ($result as $task) {
require("./templates/showtask.php");
} // <!-- foreach -->
} ?> <!-- else -->
</div> <!-- container -->
<?php require("./templates/footer.php"); ?>