-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
163 lines (146 loc) · 4.77 KB
/
index.php
File metadata and controls
163 lines (146 loc) · 4.77 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>University App</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
}
header {
font-size: x-large;
font-weight: bold;
color: white;
background-color: darkgreen;
padding: 20px;
}
header span {
border-radius: 32px;
height: 32px;
width: 32px;
color: darkgreen;
background-color: white;
display: inline-block;
}
main {
padding: 20px; /* top right bottom left */
padding: 20px 100px; /* top&bottom left&right */
}
table, td {
border: 1px solid gray;
}
.table-header {
font-weight: bold;
color: lightgray;
background-color: #333333;
}
.student-id {
text-align: center;
font-weight: bold;
text-decoration: none;
padding: 5px;
color: white;
background-color: blueviolet;
border: 1px solid gray;
border-radius: 8px;
display: block;
}
.student-id:hover {
color: yellow;
background-color: darkviolet;
}
.info {
color: darkviolet;
font-weight: bold;
}
footer {
margin-top: 20px;
text-align: center;
padding: 20px;
font-size: x-small;
background-color: lightgray;
}
.note {
font-size: small;
color: lightgray;
}
</style>
</head>
<body>
<header>
<span>Q8</span>
Universite App <?= date('H:i:s') ?>
</header>
<main>
<h1>STUDENTS LIST</h1>
<table cellspacing="0" cellpadding="10" width="100%">
<thead>
<tr class="table-header">
<td width="170">STUDENT ID NUMBER</td>
<td>STUDENT INFO</td>
</tr>
</thead>
<tbody>
<?php
// $i = 0;
// $c = 'c';
// $str = "String";
// OBJECTS ->
// DATABASE CONNECTION
$DB = mysqli_connect('127.0.0.1', 'root', '', 'universityapp_db') or die("Database Connection Error");
// SQL COMMAND EXECUTION
$result = $DB->query("SELECT * FROM view_student");
// $result = $DB->query("SELECT * FROM student");
// LISTING OF ROWS
for ($i = 0; $i < $result->num_rows; $i++) {
$row = $result->fetch_assoc();
$ALLSTUDENTS[] = $row;
?>
<tr>
<td>
<a href="#" onclick="showInfo(<?= $i ?>, <?= $row['id'] ?>)" class="student-id">
<?= $row['longIDNumber'] ?>
<?php /* $row['id'] */ ?>
</a>
</td>
<td class="info" id="info<?= $i ?>">
<!-- innerHTML -->
</td>
<?php // $row['nameLast'].', '.$row['nameFirst'].' '.$row['nameMiddle'] ?>
</tr>
<?php
// $row 1-D Associative Array
// $row = [
// 'id' => '5',
// 'fullName' => 'Five'
// ]
// echo $i.' = ' . $row['fullName']. ' ('.$row['id'].')<br>';
} ?>
<tr>
<td colspan="2" style="text-align: center">
There are
<b>
<?= $result->num_rows ?>
</b>
record/s found.</td>
</tr>
</tbody>
</table>
<script>
async function showInfo(n, id) {
console.log('showInfo: ' + n + " = " + id);
// Form Processing (GET & POST)
const response = await fetch('studentinfoloader.php?id='+id);
const text = await response.text();
document.getElementById('info' + n).innerHTML = text;
}
</script>
</main>
<footer>
<p>© 2023 by Me. All rights reserved.</p>
<p>Visit my FB page: <a href="http://fb.me/x">http://fb.me/x</a></p>
</footer>
</body>
</html>