Hello, again,
Below is my function to display the latest comments from a range of different database tables. I would like to make the actual comment a link to the actual article page, so I need to amend this function slightly.
What I would like is something like the following;
if from table artistcomments echo <a href="/artists.... etc
All I require is how to translate the 'if from artistcomments' into actual working code. I can then do the rest myself.
Many thanks
function displayLatestComments($num_comments)
{
$result = mysql_query("select artist_id
, author_id
, comment_post
, comment_date
from (
select * from cms_artistcomments
union all
select * from cms_featurecomments
union all
select * from cms_freshtalentcomments
union all
select * from cms_honeycomments
union all
select * from cms_newscomments
union all
select * from cms_multimediacomments
union all
select * from cms_reviewcomments
union all
select * from cms_wallpapercomments
) as d
order
by comment_date desc limit $num_comments");
echo '
<div class="section-heading">
Reaction Comments
</div>
<div class="basic-list">
<ul>
';
while ($row = mysql_fetch_assoc($result))
{
$user_id = $row['author_id'];
$author = mysql_query("SELECT username FROM cms_users WHERE user_id = $user_id");
$author = mysql_result($author, 0);
echo '
<li>' . $row['comment_post'] . ' <a href="/profiles/'.$user_id.'" rel="nofollow">submitted by ' . $author . '</a></li>
';
}
echo'
</ul>
</div>
';
}