-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathavgage.php
53 lines (40 loc) · 1.17 KB
/
avgage.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
<!DOCTYPE html>
<html>
<head>
<title>Book information</title>
</head>
<body>
<center>
<?php
$servername = "localhost";
$username = "root";
$password = "Project7273@";
$db = "Library";
// get the post records
$BookName = $_REQUEST['BookName'];
$Author = $_REQUEST['Author'];
$ISBN = $_REQUEST['ISBN'];
$yearPublished = $_REQUEST['yearPublished'];
$BookFormat = $_REQUEST['BookFormat'];
$Genre = $_REQUEST['Genre'];
$Pages = $_REQUEST['Pages'];
$Autorenew = $_REQUEST['Autorenew'];
$search = $_REQUEST['search'];
// Create connection
$conn = new mysqli($servername, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<?php
$query = mysqli_query($conn, "SELECT AVG(YEAR(NOW())-YEAR(Birthday)) as `Average` FROM Patrons")
or die (mysqli_error($conn));
echo"<h3>The average age of all the patrons is:</h3>";
while($row = mysqli_fetch_array($query)) {
echo $row[Average];
}
?>
</center>
</body>
</html>