<?php
try
{
	$pdo = new PDO('mysql:host=localhost;dbname=name_of_database', 'database_user', 'password');
	
	$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
	$error = 'Unable to connect to the database server.' . $e->getMessage();;
	include 'error.html.php';
	exit();
}

try
{
	$sql = 'SELECT * FROM users';
	$result = $pdo->query($sql);
}

catch (PDOException $e)
{
	$error = 'Error fetching values from database:' . $e->getMessage();
	include 'error.html.php';
	exit();
}

while ($row = $result->fetch())
{
	$lastName[] = $row['lastName'];
	$firstName[] = $row['firstName'];
	$phone[] = $row['phone'];
}
?>

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset = "utf-8">
		<title>List of People in Database</title>
	</head>
	<body>
		<p>Here are the last names in the database:</p>
		<?php foreach($lastName as $last_name): ?>
		<blockquoute>
			<p>
				<?php echo htmlspecialchars($last_name, ENT_QUOTES, 'UTF-8'); 
				?>
			</p>
		</blockquote>
		<?php endforeach; ?>
		
		<p>Here are the first names in the database:</p>
		<?php foreach($firstName as $first_name): ?>
		<blockquoute>
			<p>
				<?php echo htmlspecialchars($first_name, ENT_QUOTES, 'UTF-8'); 
				?>
			</p>
		</blockquote>
		<?php endforeach; ?>
		
		<p>Here are the phone numbers in the database:</p>
		<?php foreach($phone as $phone_number): ?>
		<blockquoute>
			<p>
				<?php echo htmlspecialchars($phone_number, ENT_QUOTES, 'UTF-8'); 
				?>
			</p>
		</blockquote>
		<?php endforeach; ?>
	</body>
</html>