The problem is uploading announcements as a div element. I looked for a way to do this through jQuery however I have very little knowledge in jQuery so I couldn't find a solution. I did find a solution through PHP which works, however it's not very elegant and I feel there is a better way to do this.
Here is the code (announcements.php):
<?php
$sql = $link->prepare('SELECT content, dateset FROM announcements WHERE email=":email"');
$sql->bindParam(':email', $_SESSION['email']);
$sql->execute();
$row = $sql->fetchAll(PDO::FETCH_ASSOC);
foreach ($row as $r) {
echo '<div class="announcement"><div class="announcementTopBar"><div class="announcementPic"><img src="smiley.png" alt="pic" width="25" height="25" /></div><span>Some Dude</span></div><div id="announcementContent"><span>';
foreach ($r as $data) {
echo $data;
}
echo '</span></div></div>';
}
?>
HTML file:
<div id="somediv">
<?php include("announcements.php"); ?>
</div>
Is there any other method I can use? Is this solution (with some refining) sufficient?