<?php
// Configuration
$hostname = 'myhost';
$username = 'myusername';
$password = 'mypassword';
$database = 'mydatabase';
try {
$dbh
= new PDO
('mysql:host='. $hostname
.';dbname='. $database, $username, $password
); } catch(PDOException $e) {
echo '<h1>An error has occurred.</h1><pre>', $e->getMessage() ,'</pre>';
}
$sth = $dbh->query(' SELECT * FROM aircraft ORDER BY cost DESC LIMIT 5');
$sth->setFetchMode(PDO::FETCH_ASSOC);
$result = $sth->fetchAll();
if(count($result) > 0) {
foreach($result as $r) {
echo $r['manufac'], " ", $r['model'], " ", $r['cost'], "\n";
}
}
?>