-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
95 lines (78 loc) · 2.06 KB
/
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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
include_once "connect-db.php";
if (isset($_POST['emptyDatabase'])) {
$result = $mysqli->query("DELETE FROM `hike`");
$result = $mysqli->query("DELETE FROM `place`");
} //END if
$hikesInDB = array();
if ($result = $mysqli->query("SELECT id, name FROM hike")) {
// if there are any results
if ($result->num_rows > 0) {
// for each result
while ($row = $result->fetch_object()) {
$hikesInDB[] = $row;
//echo $row->id;
//echo $row->name;
} //END while
} //END if
} else { echo "ERROR: Could not prepare SQL statement."; }
renderViewPage(
$hikesInDB
);
function renderViewPage(
$hikesInDB
) { ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Autograd</title>
<link rel="stylesheet" href="style-front-page.css" media="screen">
</head>
<body>
<div class="page">
<div class="page-top">
<h1>Autograd</h1>
<p>Presentation text.</p>
</div>
<div class="page-body">
<div class="page-column">
<h2>Add path from GPX file</h2>
<div class="content">
<form action="edit.php" method="POST" enctype="multipart/form-data">
<input type="file" name="gpx_file_input" id="gpx_file_input">
<input class="button" type="submit" value="Add this path">
</form>
</div>
</div>
<div class="page-column">
<h2>Hikes added <?php echo "(". count($hikesInDB) .")"?></h2>
<div id="hike-list">
<?php
if (count($hikesInDB) > 0){
echo "<ul>\n";
foreach ($hikesInDB as $key => $row) {
echo "<li><a href='view.php?hike_id=". $row->id ."'>". html_entity_decode($row->name) ."</a></li>\n";
}
echo "</ul>\n";
} //END if
?>
</div>
<?php
if (count($hikesInDB) > 0){
echo "<form action='index.php' method='POST'>\n
<input type='hidden' name='emptyDatabase'>\n
<input class='button' type='submit' value='Empty example database'>\n
</form>\n";
} //END if
?>
</div>
</div>
<div class="page-bottom">
<p>Vestlandsforskning</p>
</div>
</div>
</body>
</html>
<?php } //END function renderViewPage()
?>