Darfuria wrote: What is the best/easiest way to select the first post in a thread using PHP and SQL?
Code: Select all
$sql = 'SELECT t.stuff
, p.stuff
, pt.stuff
FROM phpbb_topics t
, phpbb_posts p
, phpbb_posts_text pt
WHERE t.topic_id = ???
and t.topic_first_post_id = p.post_id
and p.post_id = pt.post_id'
Code: Select all
<?php
mysql_connect ($dbhost, $dbuser, $dbpassword);
mysql_select_db ($dbname) or die(mysql_error());
$topics = mysql_query ("SELECT * FROM phpbb_posts INNER JOIN phpbb_posts_text ON phpbb_posts.post_id = phpbb_posts_text.post_id WHERE phpbb_posts.forum_id = " . $forumid . " ORDER BY post_time DESC") or die(mysql_error());
while($row = mysql_fetch_array($topics))
{
echo('<strong>Post ID:</strong> ' . $row['post_id'] . ' <strong>Subject:</strong> ' . $row['post_subject'] . '<br />');
}
?>
Darfuria wrote:Code: Select all
SELECT * FROM phpbb_posts INNER JOIN phpbb_posts_text ON phpbb_posts.post_id = phpbb_posts_text.post_id WHERE phpbb_posts.forum_id = " . $forumid . " ORDER BY post_time DESC"
Code: Select all
SELECT * FROM phpbb_posts INNER JOIN phpbb_posts_text ON phpbb_posts.post_id = phpbb_posts_text.post_id
inner join phpbb_topics on phpbb_posts.post_id = phpbb_topics.topic_first_post_id
WHERE phpbb_posts.forum_id = " . $forumid . " ORDER BY post_time DESC"
Darfuria wrote: Hrm. Having done this. What is the best way of parsing the BBCode?
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
Code: Select all
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
Code: Select all
$message=bbencode_second_pass($message, $message_uid)
Not very descriptive are we?Darfuria wrote: I'm still having problems