-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
59 lines (55 loc) · 2.05 KB
/
index.php
File metadata and controls
59 lines (55 loc) · 2.05 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
<?php include('db.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Management System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2>Student Management System</h2>
<form action="add_student.php" method="POST">
<h3>Add New Student</h3>
<input type="text" name="name" placeholder="Full Name" required>
<input type="number" name="age" placeholder="Age" required>
<input type="email" name="email" placeholder="Email" required>
<input type="text" name="phone" placeholder="Phone">
<button type="submit">Add Student</button>
</form>
<h3>Students List</h3>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Age</th>
<th>Email</th>
<th>Phone</th>
<th>Actions</th>
</tr>
<?php
$sql = "SELECT * FROM students";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr>
<td>".$row['id']."</td>
<td>".$row['name']."</td>
<td>".$row['age']."</td>
<td>".$row['email']."</td>
<td>".$row['phone']."</td>
<td>
<a href='edit_student.php?id=".$row['id']."'>Edit</a> |
<a href='delete_student.php?id=".$row['id']."'>Delete</a>
</td>
</tr>";
}
} else {
echo "<tr><td colspan='6'>No students found</td></tr>";
}
?>
</table>
</div>
</body>
</html>