8000 Create view_attendance.php · Abhijeetbyte/SQLite-PHP-Database@90f80ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 90f80ac

Browse files
authored
Create view_attendance.php
1 parent e52dd2a commit 90f80ac

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

view_attendance.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
try {
3+
// Connect to SQLite database
4+
$db = new PDO('sqlite:students.db');
5+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
6+
7+
// Select data from Attendance table
8+
$stmt = $db->prepare("SELECT * FROM Attendance WHERE roll_no = :roll_no");
9+
$stmt->bindParam(':roll_no', $_GET['roll_no']);
10+
$stmt->execute();
11+
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
12+
13+
if ($results) {
14+
echo "<table border='1' style='margin: 20px auto; border-collapse: collapse;'>";
15+
echo "<tr><th>ID</th><th>Roll No</th><th>Student Name</th><th>Date</th></tr>";
16+
foreach ($results as $row) {
17+
echo "<tr>";
18+
foreach ($row as $cell) {
19+
echo "<td style='padding: 10px;'>" . htmlspecialchars($cell) . "</td>";
20+
}
21+
echo "</tr>";
22+
}
23+
echo "</table>";
24+
} else {
25+
echo "No records found for roll number " . htmlspecialchars($_GET['roll_no']);
26+
}
27+
} catch (PDOException $e) {
28+
echo "Error: " . $e->getMessage();
29+
}
30+
?>

0 commit comments

Comments
 (0)
0