I'm trying to make it so it shows the latest announcements in a link with the title. I've tried doing it and now I'm just trying to get it to even return the variable and it won't...
Functions.php
<?php
require("common.php");
function getAnnouncements() {
$query = "SELECT * FROM announcements";
try {
global $db;
// Execute the query against the database
$stmt = $db->prepare($query);
$result = $stmt->execute();
echo $result['title'];
}
catch(PDOException $ex) {
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}
}
?>
index.php
<div class="announcement">
<div class="container">
Latest Announcements: <?php getAnnouncements(); echo "<a href=''></a>" ?>
</div>
</div>
Yes, I am including the file at the top and there's no spelling errors in it.