Topic: Two questions: displaying data via extern.php ...and the forum list...

Hello,

I really hope someone can help me with the following -

1. How would I make extern.php display the latest forum posts in a format "Forum, Thread Title (Replies), Last Poster, Post Date" exactly like on http://www.boards.ie ?

2. I would like to display the forum list (i.e. the section "The Cult.ie Forums" on my website http://www.cult.ie/forum/index.php) on my main non-forum index page. How would I go about selecting the snippet of code I need to use?

Any pointers very appreciated.

Thank you.

2 (edited by johnnyversace 2006-01-01 22:38)

Re: Two questions: displaying data via extern.php ...and the forum list...

OK, I got my portal up and running. If anyone needs any help with getting a portal up and running - in particular the files index.php, extern.php, header.php, common.php, functions.php, footer.php - let me know. I can probably help you.

QUESTION: On my website http://www.cult.ie, in the section "Latest Forum Posts" you can see I want to display the FORUM, the USER/POSTER and the TIME of the post. Could someone please tell me what SQL I need to use to get these values? It will be related to the following SQL from extern.php -

$result = $db->query('SELECT t.id, t.subject FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

Thank you!!!

Re: Two questions: displaying data via extern.php ...and the forum list...

Got everything working. You can see the results at http://www.cult.ie

Maybe this will be helpful for some people -

I used the following to extract the poster of the most recent topics -

$result_username = $db->query("SELECT u.id, u.username FROM ".$db->prefix."users as u WHERE u.username='".$cur_topic['last_poster']."'");

$user_data = $db->fetch_assoc($result_username);
if (!$user_data['id'])
    echo 'Guest';
else
    echo '<a href="./forum/profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data["username"]).'</a>';

I used the following to extract what forum the post belongs to -

$result_forum = $db->query("SELECT f.id, f.forum_name FROM ".$db->prefix."forums as f WHERE f.id='".$cur_topic['forum_id']."'");

$user_data = $db->fetch_assoc($result_forum);
echo '<a href="./forum/viewforum.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data["forum_name"]).'</a>';

I used the following to display the time of the most recent post -

format_time($cur_topic["last_post"])

Note that I changed the SQL in extern PHP to -

$result = $db->query('SELECT t.id, t.subject, t.last_poster, t.last_post, t.forum_id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

(As you can see it is basically just selecting more items.)

Hopefully this is helpful!!

PS Punbb seems great so far.

4

Re: Two questions: displaying data via extern.php ...and the forum list...

Everything worked quite nicely except for the date. Could you elaborate?

-gezz

5

Re: Two questions: displaying data via extern.php ...and the forum list...

Everything is fixed and working. I used page scraping because my host disabled includes with parameters. This helped alot.

-gezz

6

Re: Two questions: displaying data via extern.php ...and the forum list...

johnnyversace,
great work on the recent posts table for the mainpage. Can you share the detailed codes for that?

thanks