Hallo!!
Ich habe folgendes Skript geschrieben:
Im zweiten SELECT kann er eine Tabellenspalte (die auswahl des Users) nicht finden. Ich komme aber nicht dahinter wo der fehler liegt.
Könnt ihr mir bitte helfen?

Im Anhang ist eine Darstellung RDBMS
Ich habe folgendes Skript geschrieben:
Code:
<!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', '' ); //$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, region_id FROM regions ORDER BY name"; $stmt = $pdo -> prepare($sql); $stmt -> execute(); //print_r($stmt->fetchAll(PDO::FETCH_ASSOC)); echo "<select name ='auswahl' id = 'auswahl'>"; foreach ($stmt->fetchAll(PDO::FETCH_COLUMN,0) as $daten) echo "<option value = $daten>".$daten."</option>"; echo "</select>"; if(isset($_POST['auswahl'])){ $region = $_POST['auswahl']; print_r($_POST['auswahl']); /* $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 AND countries.country_id = country_stats.country_id AND regions.region_id = '.$region.' 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>
Könnt ihr mir bitte helfen?
Im Anhang ist eine Darstellung RDBMS
Kommentar