Sorry, code is actually from XMB Forum - php forum / Subversion / [r3058] /xmb19x/trunk/source/memcp.php
I used generic/loose code as I wasn’t sure what the policy was.
I don’t have name numbered columns.
$query = $db->query(
"SELECT t.tid, t.fid, t.icon, t.lastpost, t.subject, t.replies, r.uid AS lastauthor
FROM ".X_PREFIX."favorites f
INNER JOIN ".X_PREFIX."threads t USING (tid)
LEFT JOIN ".X_PREFIX."members AS r ON SUBSTRING_INDEX(SUBSTRING_INDEX(t.lastpost, '|', 2), '|', -1) = r.username
WHERE f.username='$xmbuser' AND f.type='subscription'
ORDER BY t.lastpost DESC
LIMIT {$mpage['start']}, $tpp"
);
$subnum = 0;
$subscriptions = '';
$tmOffset = ($timeoffset * 3600) + ($SETTINGS['addtime'] * 3600);
while($fav = $db->fetch_array($query)) {
$forum = getForum($fav['fid']);
$forum['name'] = fnameOut($forum['name']);
$lastpost = explode('|', $fav['lastpost']);
// Translate "Anonymous" author.
$lastpostname = trim( $lastpost[1] );
if ( 'Anonymous' == $lastpostname ) {
$lastpostname = $lang['textanonymous'];
}
$lastreplydate = gmdate($dateformat, $lastpost[0] + $tmOffset);
$lastreplytime = gmdate($timecode, $lastpost[0] + $tmOffset);
$lastpost = $lang['lastreply1'].' '.$lastreplydate.' '.$lang['textat'].' '.$lastreplytime.' '.$lang['textby'].' '.$lastpostname;
$fav['subject'] = rawHTMLsubject(stripslashes($fav['subject']));
if ($fav['icon'] != '') {
$fav['icon'] = '<img src="'.$smdir.'/'.$fav['icon'].'" alt="" border="0" />';
} else {
$fav['icon'] = '';
}
I was looking to add a function as wanted to get additional rows from the threads table and include them on the $fav[‘subject’] variable.
$forum = getForum($fav[‘fid’])* certainly gives an example of a function but trying to get my head around functions for string building and my head is swimming. I have done it without a function but it would be neater with it. Thanks anyway.
// from https://sourceforge.net/p/xmb-forum/code/HEAD/tree/xmb19x/trunk/source/include/functions.inc.php
function getForum($fid) {
global $db;
$forums = forumCache();
while($forum = $db->fetch_array($forums)) {
if (intval($forum['fid']) == intval($fid)) {
return $forum;
}
}
return FALSE;
}