-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql.php
More file actions
38 lines (29 loc) · 833 Bytes
/
mysql.php
File metadata and controls
38 lines (29 loc) · 833 Bytes
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
<html>
<head>
<title>Life Expectancy</title>
<h1>Life Expectancy for North America listed in Years High to Low</h1>
</head>
<body>
<br>
<?php
include('mysqli_connect.php');
echo 'connected to the database' . '<br>';
$res=mysqli_query($db, "select name,continent,lifeexpectancy from country where continent='North America' order by lifeexpectancy desc");
echo 'query worked' . '<br>';
echo '<table border=2 cellpadding=10>';
echo '<tr><th>Name</th><th>Continent</th><th>Life Expectancy</th></tr>';
while ($row = $res->fetch_object()){
echo '<tr>';
echo '<td>' . $row->name . '</td>';
echo '<td>' . $row->continent . '</td>';
echo '<td>' . $row->lifeexpectancy . '</td>';
echo '</tr>';
}
echo '<table>';
mysqli_free_result($res);
echo 'result free' . '<br>';
mysqli_close($db);
echo 'closed the database';
?>
</body>
</html>