-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
180 lines (149 loc) · 7.03 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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
include "config.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" href="styles/style.css">
<style>
td {
text-align: center;
}
</style>
</head>
<body onload="view()">
<script src="scripts/script.js"></script>
<div class="container">
<div class="buttons">
<button onclick="view()">View</button>
<button onclick="add()">Add</button>
<button onclick="edit()">Edit</button>
<button onclick="del()">Delete</button>
<button onclick="search()">Search</button>
</div><br>
<div class="view box" id="view">
<table>
<tr>
<th>Student ID</th><th>Student Name</th><th>Student Age</th><th>Student Address</th><th>Image</th>
</tr>
<?php
$sql = "SELECT * FROM student";
$result = $conn->query($sql);
if ($result -> num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$id = $row['studentID'];
$name = $row['studentName'];
$age = $row['studentAge'];
$address = $row['studentAddress'];
$image = $row['imgLoc'];
echo '<tr><td>'.$id.'</td><td>'.$name.'</td><td>'.$age.'</td><td>'.$address.'</td>';
if ($image == NULL)
{
echo '<td><h4>No<br>Image</h4></td></tr>';
}
else
{
echo'<td>';
echo'<img src="'.$image.'" alt="" style = "width:50px; height:50px; margin-top:5px;">';
echo'</td></tr>';
}
}
}
?>
</table>
</div>
<div class="add box" id="add">
<div class = "border">
<form action="addStudentValidate.php" method = "POST" enctype = "multipart/form-data">
<p>Student Name : <input type="text" name = "name"></p><br>
<p>Student Age : <input type="text" name = "age"></p><br>
<p>Student Address : <input type="text" name = "address"></p><br>
<p>Student Image : <input type="file" name = "image"></p><br>
<input type = "submit" value = "Add Details" class = "button">
<input type = "reset" value = "Reset" class = "button">
</form>
</div>
</div>
<div class="edit box" id="edit">
<table>
<tr>
<th>Student ID</th><th>Student Name</th><th>Student Age</th><th>Student Address</th><th>Image</th><th></th>
</tr>
<?php
$sql = "SELECT * FROM student";
$result = $conn->query($sql);
if ($result -> num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$id = $row['studentID'];
$name = $row['studentName'];
$age = $row['studentAge'];
$address = $row['studentAddress'];
$image = $row['imgLoc'];
echo '<tr><td>'.$id.'</td><td>'.$name.'</td><td>'.$age.'</td><td>'.$address.'</td>';
if ($image == NULL)
{
echo '<td><h4>No<br>Image</h4></td>';
}
else
{
echo'<td>';
echo'<img src="'.$image.'" alt="" style = "width:50px; height:50px; margin-top:5px;">';
echo'</td>';
}
echo '<td><a href="editStudent.php?id='.$id.'"><button class = "validate">Edit Student<br>Details</button></a></tr></td>';
}
}
?>
</table>
</div>
<div class="delete box" id="delete">
<table>
<tr>
<th>Student ID</th><th>Student Name</th><th>Student Age</th><th>Student Address</th><th>Image</th><th></th>
</tr>
<?php
$sql = "SELECT * FROM student";
$result = $conn->query($sql);
if ($result -> num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$id = $row['studentID'];
$name = $row['studentName'];
$age = $row['studentAge'];
$address = $row['studentAddress'];
$image = $row['imgLoc'];
echo '<tr><td>'.$id.'</td><td>'.$name.'</td><td>'.$age.'</td><td>'.$address.'</td>';
if ($image == NULL)
{
echo '<td><h4>No<br>Image</h4></td>';
}
else
{
echo'<td>';
echo'<img src="'.$image.'" alt="" style = "width:50px; height:50px; margin-top:5px;">';
echo'</td>';
}
echo '<td><a href="deleteStudent.php?id='.$id.'"><button class = "validate">Delete Student</button></a></tr></td>';
}
}
?>
</table>
</div>
<div class="search box" id="search">
<div class = "searchform">
<form action="searchResults.php" method = "POST">
<p>Enter Student Name : <input type="text" name = "name" required></p><br>
<input type = "submit" value = "Search" class = "button">
<input type = "reset" value = "Reset" class = "button">
</form>
</div>
</div>
</div>
</body>
</html>