Topic: viewtopic.php show group names

Hi.

I'm trying to modify viewtopic.php to display group names on posts, but the SQL query
on line 186 is currently beyond me (I've been programming for a long time, but I effectively
started SQL yesterday).

The huge query is as follows:

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.avatar_url, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
while ($cur_post = $db->fetch_assoc($result))
{
  ...

Now later on in the code, I'd like to be able to effectively use:

$cur_post['g_title']

..to get the group title of the current poster. Could anybody explain to me how to
modify the above query to allow this? Is it actually possible?

Re: viewtopic.php show group names

Well... It's not as easy as you think... depending...

$cur_post['g_title'] is the name of the group, as far as administrators are concirned (It's the first line that's displayed when you edit a group)
$cur_post['g_user_title'] is the description (or display name, or title) of the group (as long as ranks are disabled and the user title hasn't been set; second line in edit groups).

Just add ", g.g_title " after the first ", g.g_user_title" to get the group name. Then $cur_post['g_title'] will be set, and you can echo it wherever big_smile

Now if you want the title, of the group to display... well that's work, since sometimes g_user_title is NULL, and sometime users.title is NULL and sometimes ranks don't exists or are turned off...

echo "deadram"; echo; fortune;

Re: viewtopic.php show group names

It worked nicely. Thanks!

We always disable user ranks anyway, so that wasn't a problem.