Jump to content

help with db call


far2slow

Recommended Posts

 

i dont know if anyone can help with this, what i am trying to do is get a mebergroup and list the mebers in that group and make sure if the user is in a additional group is included in the list eg admin mods

i may be way off with this at the moment 

 

{
   global $context, $scripturl, $txt, $settings, $user_info, $modSettings, $smcFunc ;

   // Grab  the team group
   $request = $smcFunc['db_query']('', '
      SELECT mg.id_group, mg.group_name, mg.online_color, mg.stars
      FROM ({db_prefix}membergroups AS mg
      WHERE mg.id_group = 19
      ORDER BY mg_online_color', array()
   );
   
   while ($row = $smcFunc['db_fetch_assoc']($request))
   {
      $row['stars'] = empty($row['stars']) ? array('', '') : explode('#', $row['stars']);

      $context['display_groups'][$row['id_group']] = array(
         'name' => $row['group_name'],
         'color' => $row['online_color'],
         'image' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($row['stars'][1]) ? $settings['images_url'] . '/' . $row['stars'][1] : '') . '" alt="*" border="0" />', empty($row['stars'][0]) || empty($row['stars'][1]) ? 0 : $row['stars'][0]),
         'members' => array(),
        
      );
        
      {
         $query_members = $smcFunc['db_query']('', '
            SELECT
               mem.id_member, mem.id_group, mem.real_name, mem.usertitle,
               IFNULL(lo.log_time, 0) AS is_online,
               IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
            FROM {db_prefix}members AS mem
               LEFT JOIN {db_prefix}log_online AS lo ON (lo.id_member = mem.id_member)
               LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
            WHERE mem.id_group = {int:id_group} ' . (!empty($modSettings['team_additional_groups']) ? 'OR FIND_IN_SET({int:id_group}, mem.additional_groups)' : '') . '
            ORDER BY mem.real_name ASC',
            array(
               'id_group' => $row['id_group'],
            )
         );
      }

Link to comment
https://forums.phpfreaks.com/topic/242727-help-with-db-call/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.