forked from AtitBimali/web-tech-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
student_info.php
59 lines (48 loc) · 1.4 KB
/
student_info.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
<?php
// Establish a connection to the MySQL server
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "student";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Retrieve data from the "student_info" table
$sql = "SELECT * FROM student_info";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Information</title>
</head>
<body>
<h2>Student Information</h2>
<?php
// Display data in a table
if ($result->num_rows > 0) {
echo "<table border='1'>";
echo "<tr><th>ID</th><th>Full Name</th><th>Course</th><th>Semester</th><th>Email</th><th>Phone Number</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>".$row["id"]."</td>";
echo "<td>".$row["fullName"]."</td>";
echo "<td>".$row["course"]."</td>";
echo "<td>".$row["semester"]."</td>";
echo "<td>".$row["email"]."</td>";
echo "<td>".$row["phoneNo"]."</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "No records found";
}
// Close the database connection
$conn->close();
?>
</body>
</html>