I worked with the extern.php file and got it to print the 15 recent posts with links. But I'd still like to add the poster and forum_name(linked) to the output like this:
subject(linked) : poster : forum_name(linked)
So while fetching from the database, I need the poster, forum_id, then the forum_name from the other table, and whatever is needed to link to the forum. Any suggestions would be appreciated.
Here's the code I'm working with:
--------
It's currently set up to display a list of the 15 most recent posts, with links to the posts:
subject(linked)
I want to do:
subject(linked) : poster : forum_name(linked)
//
// active2 (show recently active topics as 'subject(linked) : poster : forum_name(linked)') (HTML)
//
//
if ($_GET['action'] == 'active2')
{
$order_by = ($_GET['action'] == 'active2') ? 't.last_post' : 't.posted';
$forum_sql = '';
// Was a forum ID supplied?
if (isset($_GET['fid']))
{
$fid = intval($_GET['fid']);
if (!empty($fid))
$forum_sql = 'f.id='.$fid.' AND ';
}
// Should we output this as RSS?
// Code removed
// Output regular HTML
// else
// {
$show = intval($_GET['show']);
if ($show < 1 || $show > 50)
$show = 15;
// Fetch $show topics
$result = $db->query('SELECT t.id, t.subject FROM '.$db->prefix.'topics AS t INNER JOIN
'.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.moved_to IS NULL AND
'.$forum_sql.'f.admmod_only=0 ORDER BY '.$order_by.' DESC LIMIT '.$show) or
error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
while ($cur_topic = $db->fetch_assoc($result))
{
if ($pun_config['o_censoring'] == '1')
$cur_topic['subject'] = censor_words($cur_topic['subject']);
if (pun_strlen($cur_topic['subject']) > $max_subject_length)
$subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
else
$subject_truncated = $cur_topic['subject'];
echo '<b>·</b> <a href="'.$pun_config['o_base_url'].'/viewtopic.php?
id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.
pun_htmlspecialchars($subject_truncated).'</a><br>'."\n";
}
// }
exit;
}
(I added some linebreaks to minimize the horizontal scrolling.)