Topic: Modifying Index Page MySQL Query

This might be the wrong forum - if it is, please feel free to move it.

Here is the MySQL query for the index page which calls up the list of forums:

$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.forum_assoc FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_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 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

I would like to have it also include the title of the last post...any ideas on how to modify the query?

NFL-Forums.com administrator

Re: Modifying Index Page MySQL Query

OK, for what its worth, I changed the sql to this:

$result = $db->query('SELECT t.id AS tid, t.subject, t.num_replies, p.id AS pid,p.topic_id, c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.forum_assoc FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id INNER JOIN '.$db->prefix.'posts AS p ON p.id=f.last_post_id INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_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 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

The problem with this is that it does not show empty forums...any help?

NFL-Forums.com administrator

Re: Modifying Index Page MySQL Query

http://wiki.punres.org/Last_post%27s_su … orum_index

Looking for a certain modification for your forum? Please take a look here before posting.