-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowingList.php
138 lines (115 loc) · 3.22 KB
/
showingList.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
//connect to database
require_once('database.php');
// Get category ID
if (!isset($unitID)) {
$unitID = filter_input(INPUT_GET, 'unitID',
FILTER_VALIDATE_INT);
if ($unitID == NULL || $unitID == FALSE) {
$unitID = 1;
}
}
//get all units
$query = 'SELECT * FROM units
ORDER BY unitID';
$statement1 = $db->prepare($query);
$statement1->execute();
$units = $statement1->fetchAll();
$statement1->closeCursor();
//get unit information
$queryUnit = 'SELECT * FROM units
WHERE unitID = :unitID';
$statement2 = $db->prepare($queryUnit);
$statement2->bindValue(':unitID', $unitID);
$statement2->execute();
$selectedUnit = $statement2->fetch();
$statement2->closeCursor();
//get all showings
$query = 'SELECT * FROM showings
WHERE unitID = :unitID';
$statement3 = $db->prepare($query);
$statement3->bindValue(':unitID', $unitID);
$statement3->execute();
$showings = $statement3->fetchAll();
$statement3->closeCursor();
?>
<!doctype html>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
</head>
<body>
<div class="wrapper">
<nav>
<?php include_once('navigation.php')?>
</nav>
<header>
<div class="hero">
</div>
<h1><?php echo $selectedUnit['address'] ?></h1>
</header>
<main>
<div class="rightNavigation">
<form action="showingList.php.?unitID=<?php echo $unit['unitID']; ?>">
<caption>Select a Unit</caption><br>
<select name="unitID">
<?php foreach ($units as $unit) : ?>
<option value="<?php echo $unit['unitID']; ?>"><?php echo $unit['address']; ?></option>
<?php endforeach; ?>
</select>
<br>
<input type="submit">
</form>
<form action="addShowing.php" method="post">
<table>
<caption>Add a new Showing</caption>
<tr>
<td>Date</td>
<td><input type="date" name="date"></td>
</tr>
<tr>
<td>Time</td>
<td><input type="time" name="time"></td>
</tr>
</table>
<input type="hidden" name="unitID" value="<?php echo $unitID; ?>">
<td><input type="submit" value="Add Showing"></td>
</form>
</div>
<table>
<caption>Scheduled Showings</caption>
<tr>
<th>Date</th>
<th>Time</th>
<th>Attendees</th>
<th> </th>
</tr>
<!-- display a list of showings for the selected unit -->
<?php foreach ($showings as $showing ) : ?>
<tr>
<td class="middle"><?php echo $showing['date'] ?></td>
<td class="middle"><?php echo $showing['time'] ?></td>
<td class="middle"> </th>
<td class="right"><form action="deleteShowing.php" method="post">
<input type="hidden" name="showingID"
value="<?php echo $showing['showingID']; ?>">
<input type="submit" value="Delete">
</form></td>
<td class="right"><form action="showingAttendeeList.php" method="post">
<input type="hidden" name="showingID"
value="<?php echo $showing['showingID']; ?>">
<input type="submit" value="View">
</form></td>
</tr>
<?php endforeach; ?>
</table>
</main>
<!-- <div style="clear: both;"> </div> -->
</main>
<footer>
<?php include_once('footer.php')?>
</footer>
</div>
</body>
</html>