<?php
$query = "SELECT
posts.post_id,
posts.post_by,
users.user_id,
users.user_name,
topics.topic_id,
topics.topic_cat
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
LEFT JOIN
topics
ON
posts.post_topic = topics.topic_id
WHERE
topic_id = '" . (int)$actual . "'
ORDER BY
post_id DESC
LIMIT
1";
$checkpost = mysql_query($query) OR die(mysql_error());
if(!$checkpost) {
echo '<em>' . $lang['no_one'] . '</em>';
}else{
if(intval(mysql_num_rows($checkpost)) == 0) {
echo '<em>' . $lang['no_one'] . '</em>';
}else{
while($lastrep = mysql_fetch_assoc($checkpost)) {
$lastpost = '<a href="profile.php?user_id=' . (int)$lastrep['user_id'] . '" class="topics">' . htmlentities($lastrep['user_name'], ENT_QUOTES) . '</a>';
}
}
}
?>