-
Notifications
You must be signed in to change notification settings - Fork 5
/
father.php
50 lines (39 loc) · 1.43 KB
/
father.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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "DBMS";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE STUDENT SET FATHER_NAME='$_POST[father]' WHERE STU_ID='$_POST[sid]'";
$stmt = $conn->prepare($sql);
$stmt->execute();
echo $stmt->rowCount() . "<table style='border: solid 1px black;'>";
echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th><th>FATHER'S NAME</th><th>DOB</th><th>BRANCH</th><th>CGPA</th><th>HOSTEL ID</th><th>MESS ID</th><th>ROOM NO</th></tr>";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
} $stmt = $conn->prepare("SELECT * FROM STUDENT");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>