';
/*** set the error reporting attribute ***/
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "
Selection of all the articles
";
/*** SQL Query ***/
$query = "select article.name as name, article.price as price, category.name
as category from article, category where article.categoryID=category.categoryID";
/*** loop of the results ***/
foreach ($dbh->query($query) as $row)
{
echo $row['name'].', ';
echo $row['price'].', ';
echo $row['category']."
\n";
}
/*** close the database connection ***/
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>