WebServ/www/public/M6/01/index.php

25 lines
701 B
PHP
Raw Permalink Normal View History

2024-09-19 11:47:33 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M6 | 01</title>
</head>
<body>
<?php
2024-10-07 06:18:58 +00:00
include_once('../inc/world_connect.php');
2024-09-19 11:47:33 +00:00
/* Kör frågan mot databasen world och tabellen country */
$stmt = $db->prepare("SELECT Name, Population FROM country WHERE Name LIKE 'Z%' ORDER BY Population DESC");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach( $result as $row ){
echo "<strong>Country: </strong>".$row['Name'];
echo " <strong>Population: </strong>".$row['Population'];
echo "<br /><hr />";
}
?>
</body>
</html>