<?php
$db_hostname = 'localhost';
$db_database = 'me23rw_Workshop5'; //'me23rw_Workshop5'
$db_username = 'me23rw_me23rw'; //'me23rw_me23rw';
$db_password = 'SnoweyShadows73'; //'P@ndaP0p73';
$db_connection_string = "mysql:host=$db_hostname;dbname=$db_database";
$db_status = 'not initialised';
$content = '';
try {
//create a connection object
$conn = new PDO($db_connection_string, username: me23rw $db_username, P@ndaP0p73 $db_password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db_status = "Connected successfully";
} catch(PDOException $e) {
$db_status = "Connection failed: " . $e->getMessage();
}

// Keep the existing database connection code here
$stm = $conn->query("SELECT * FROM MusicRevenue");
$rows = $stm->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $row) {
$content .= "<em>" . $row['Outlet'] . "</em>: " . $row['PPM'] . "<br />";
}

// Close connection to database
$conn = null;
?>
<!DOCTYPE html>
<html>
<head>
<title>Using Data</title>
</head>
<body>
<h1>Pokemon Type Management</h1>
<h4>Sorting through Pokemon and their types:</h4>
<p>
Database <?php echo $db_database; ?>...
<strong><?php echo $db_status; ?></strong>
</p>
<!-- This is where our data will be printed out: -->
<?php echo $content; ?>
<p><em>Data from <a href='https://www.kaggle.com/datasets/lunamcbride24/pokemon-type-matchup-data?resource=download'>
Kaggle.com</a></em></p>
</body>
</html>
