45 lines
1.6 KiB
PHP
45 lines
1.6 KiB
PHP
<!DOCTYPE HTML>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Länderdaten nach Regionen</title>
|
|
<?php
|
|
try {
|
|
$pdo = new PDO ( 'mysql:dbname=nation;charset=utf8', 'root', 'Feuerwehr1!' );
|
|
//$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
//$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
|
} catch ( PDOException $e ) {
|
|
die ( $e->getMessage () );
|
|
}
|
|
?>
|
|
</head>
|
|
<body>
|
|
<form method="post">
|
|
<?php
|
|
$sql = "SELECT name FROM regions ORDER BY name";
|
|
$stmt = $pdo -> prepare($sql);
|
|
$stmt->execute();
|
|
//print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
|
|
echo "<select name ='konti' id = 'konti'>";
|
|
foreach ($stmt->fetchAll(PDO::FETCH_COLUMN,0) as $daten)
|
|
echo "<option value = $daten>".$daten."</option>";
|
|
echo "</select>";
|
|
|
|
|
|
|
|
if(isset($_POST["konti"])){
|
|
print_r($_POST["konti"]);
|
|
$auswahl = "SELECT countries.name, countries.area, country_stats.gdp AS 'AVG BIP', country_stats.population, continents.name FROM
|
|
countries, country_stats, regions INNER JOIN continents ON regions.continent_id = continents.continent_id
|
|
WHERE regions.region_id = countries.region_id && countries.country_id = country_stats.country_id AND regions.name ='". $_POST['konti']."' GROUP BY countries.country_id";
|
|
$stmt = $pdo->prepare($auswahl);
|
|
$ausgabe[] = $stmt->execute();
|
|
foreach ($ausgabe as $ausgeben)
|
|
echo $ausgeben;
|
|
}
|
|
?>
|
|
<br>
|
|
<input type = "submit" value ="anzeigen">
|
|
</form>
|
|
</body>
|
|
</html>
|