This repository has been archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
view.php
executable file
·127 lines (110 loc) · 4.01 KB
/
view.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
<?php
include 'secrets.php';
$db = mysqli_connect("localhost", "root", MYSQL_SECRET, $dbname);
if (!$db) {
die('<p class="error">Connect Error ('.mysqli_connect_errno().') '. mysqli_connect_error()."</p>");
}
if(isset($_POST['year'])) {
$year = $_POST['year'];
} else {
$year = "2021-2022";
}
$query = "SELECT * FROM `". $year ."` ORDER BY `". $year ."`.`name` ASC";
$query_count = "SELECT count(*) as num_people FROM `". $year ."`";
$results = $db->query($query);
$results_count = $db->query($query_count);
?>
<?php
$title = "View Members";
include 'header.php';
?>
<head>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">
</head>
<!-- Page Heading/Breadcrumbs -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><?php echo $title ?></h1>
<ol class="breadcrumb">
<li><a href="index.php">Home</a>
</li>
<li class="active"><?php echo $title ?></li>
</ol>
</div>
</div>
<!-- /.row -->
<div class="container">
<div class="row">
<div class="col-lg-10">
<form method="post" action="" class="text-dark">
<select name="year" class="form-control" style="width: 200px; display: inline-block;">
<option value="2021-2022">Select Year</option>
<option value="2021-2022">2021 - 2022</option>
<option value="2020-2021">2020 - 2021</option>
<option value="2019-2020">2019 - 2020</option>
<option value="2018-2019">2018 - 2019</option>
<option value="2017-2018">2017 - 2018</option>
</select>
<input type="submit" class="btn btn-default" value="Go!"/>
</form>
<br />
</div>
</div>
</div>
<!-- Well -->
<div class="well text-dark">
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<?php
$count = mysqli_fetch_array($results_count);
echo "<h1><center>$count[num_people] Members</center></h1>";
?>
<table class="table table-striped" id="tblMembers" class="display">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Enterer</th>
<th>Committee</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($results)) {
$name = $row['name'];
$email = $row['email'];
$enterer = $row['enterer'];
$committee = $row['committee'];
echo "<tr>";
echo "<td>$name</td>";
echo "<td>$email</td>";
echo "<td>$enterer</td>";
echo "<td>$committee</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<!-- /.well -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<script type="application/javascript">
</script>
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script>
function selectyear() {
var year = document.getElementById('year').value;
$.post("view.php", {
year: year
}, function(ret) {});
}
$(document).ready(function() {
$('#tblMembers').DataTable();
});
</script>
<?php
include 'footer.php';
?>