I have successfully installed the blog scripts and now I'm trying to do extend my programming abilities. As suggested by the author I am trying to build up and create something specific for my needs. I would like to be able to print out comments with each blog entry together with the username and avatar: something similar to the Forum which I am using as a guide to do the same here. However, although my script prints out all the correct information for each post_id, it does not separate between the blog entries; it dumps the same information into each blog. Does anyone have any suggestions how to identify the correct blog; it would be much appreciated.
Code:
// retrieve avatar for this post
$id = (int)$_GET['post_id'];
$query = <<<ENDSQL
SELECT
USERNAME, POST_COMMENT,
UNIX_TIMESTAMP(COMMENT_DATE) AS COMMENT_DATE
FROM
ALBION_BLOG_COMMENT B JOIN ALBION_USER U
ON B.USER_ID = U.USER_ID
ORDER BY COMMENT_DATE ASC
ENDSQL;
$query = sprintf($query, DB_TBL_PREFIX, $id);
$result = mysql_query($query, $GLOBALS['DB']);
if (mysql_num_rows($result))
{
while($row = mysql_fetch_assoc($result))
{
echo htmlspecialchars($row['USERNAME']) . '<br/>';
echo date('m/d/Y', $row['COMMENT_DATE']) . '<br/>';
echo htmlspecialchars($row['POST_COMMENT']) . '<br/>';
if (file_exists('avatars/' . $row['USERNAME'] . '.jpg'))
{
echo '<img src="avatars/' . $row['USERNAME'] . '.jpg" alt="avatar"/><br/>';
}
else
{
echo '<img src="img/default_avatar.jpg" alt="avatar"/><br/>';
}
}
}