$sql = "SELECT * FROM Books"; $result = $pdo->query($sql); // fetch a record into an object of type Book while ( $b = $result->fetchObject('Book') ) { // the property names match the field names from the table echo 'ID: ' . $b->ID . '
'; echo 'Title: ' . $b->Title . '
'; echo 'Year: ' . $b->CopyrightYear . '
'; echo 'Description: ' . $b->Description . '
'; echo "
"; }