forked from ameinzinger/Assignment-cool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex2.php
More file actions
79 lines (59 loc) · 1.66 KB
/
index2.php
File metadata and controls
79 lines (59 loc) · 1.66 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
require "public/templates/header.php";
try {
require "config.php";
require "common.php";
// $connection = new PDO ( $dsn, $username, $password, $options );
$connection = new PDO ( $dsn );
$sql = "SELECT * FROM coverage";
$statement = $connection->prepare ( $sql );
$statement->execute ();
$result = $statement->fetchAll (PDO::FETCH_ASSOC);
} catch ( PDOException $error ) {
echo $sql . "<br>" . $error->getMessage ();
}
?>
<h2>Results</h2>
<table>
<thead>
<tr>
<th>#</th>
<th>Coverage Name</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<?php
$className = "'confirmation'";
foreach ( $result as $row ) {
?>
<tr>
<td><?php echo escape($row["id"]); ?></td>
<td><?php echo escape($row["coverage_name"]); ?></td>
<td><?php echo escape($row["cost"]); ?></td>
<td><?php echo "<a href=" . "update.php?id=" . $row["id"] . ">" . "Update</a>" ?> </td>
<td><?php echo "<a href=" . "delete.php?id=" . $row["id"] . " class=" . $className . "> Delete </a>" ?> </td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
// }
?>
<a href="index.php">Back to home</a>
<?php require "templates/footer.php"; ?><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simple Database App</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>Simple Database App</h1>
<a href="install.php">Install Database</a></br>
<a href="public/index.php">Home</a>
</body>