Countries with highest populations!
Population
city | populaton |
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$country = $_GET['country'];
#allows for sanitized data user can't input SQL queries into params
$cleanCountry = $db->quote($country);
print $cleanCountry;
$rows = $db->query("SELECT ci.name, ci.population FROM cities ci
JOIN countries co ON co.code = ci.country_code
WHERE co.name = {$cleanCountry}
ORDER BY ci.population DESC
LIMIT 10;");
foreach($rows as $row) {
?>
---|
=$row["name"]?> | =$row["population"]?> |