File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
+ ?>
You can’t perform that action at this time.
0 commit comments