Right, what I'm trying to do is fetch the first post in the topic, the actual post of the topic creator - this is for news, a full news view so to say (when you click the news you come to this page - Page with the news and the comments after).
Ive already managed to get all the comments, but having trouble getting a query only for the first post.
This is what it looks for the code for fetching the first topic post looks like at the moment:
// Fetch some info about the news
$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted
FROM '.$db->prefix.'topics AS t
INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id
INNER JOIN ' . $db->prefix . 'posts AS p ON topic_id='.$id.'
INNER JOIN ' . $db->prefix . 'users AS u ON u.id=p.poster_id
LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')
WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
$cur_topic = $db->fetch_assoc($result);
$cur_post = $db->fetch_assoc($result);
while($cur_post)
{
$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
echo '
<h1>'.$cur_topic['subject'].'</h1>
<p>'.$cur_post['message'].'<br /></p>
<h3>'.$news_actions.'</h3>
';
$cur_post = $db->fetch_assoc($result);
if( $cur_post ) echo '';
}
}
and Its not working properly (just giving me all the posts after the first post at the moment).
Could anyone help me with this?