News:

Wondering if this will always be free?  See why free is better.

Main Menu

Calling a particular membergroup

Started by Biology Forums, February 14, 2011, 06:03:39 PM

Previous topic - Next topic

Biology Forums

Can someone please tell me how to call a list of members in a particular membergroup? For instance, I want to make a table of all the members who have donated (who are in the donated membergroup) and I want this to show on a particular board. What is the code I have to put in the message.board.template.php to make this happen.

I am using 1.1.13.

Thx


Matthew K.

You'd most likely need to write a query to load all of the members inside that group into an array. I don't think there are any arrays that have all of the members inside their groups.

Arantor

There aren't any arrays, no. What's up, Labradoodle, I'm sure I gave you code for this more than once...

Matthew K.

Yeah, I'm sure you did. The difference is, I could write it myself now. You definitely helped me learn a thing or two :)

Biology Forums

You guys have the code for this? The membergroup is number 12 and it only consists of 3 members

Matthew K.

I don't have the code for anything like this...at least, anymore. I could write it however.

Biology Forums

would it be difficult? Would you have to modify the ssi?

Matthew K.

You wouldn't have to modify SSI at all...you'd just need to write a simple query to pull all members that are in either of those groups...

Biology Forums

could you provide a quick tutorial or an example?

Arantor

Just getting usernames:


global $smcFunc;
$members = array();
$query = $smcFunc['db_query']('', '
  SELECT id_member, real_name
  FROM {db_prefix}members
  WHERE id_group = {int:group} OR id_post_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0
  ORDER BY real_name',
  array(
    'group' => 12,
  )
);
while ($row = $smcFunc['fetch_assoc']($query))
  $members[$row['id_member']] = $row['real_name'];
$smcFunc['db_free_result']($query);

echo implode(', ', $members);

Matthew K.


Arantor

This is what I get for all that typing on an iPad... :(

Matthew K.

Blah sorry....if I remembered how to write 1.1. queries without reviewing one of my old ones, I'd write it up. But I really don't want to have to look at 1.1 code unless I have to.

Arantor

$members = array();
$query = db_query("
  SELECT ID_MEMBER, realName
  FROM {$db_prefix}members
  WHERE ID_GROUP = 12 OR ID_POST_GROUP = 12 OR FIND_IN_SET(12, additionalGroups)
  ORDER BY realName", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
  $members[$row['ID_MEMBER']] = $row['realName'];
mysql_free_result($query);

echo implode(', ', $members);

Biology Forums

Sorry Arantor, but if I want to embed this into the message.board.template.php, would I simply have to copy-and-paste the code where I want it to appear?

Arantor


Matthew K.

And what about not having queries in templates?

Arantor

Yes, we shouldn't. But I don't have the code in front of me to find where it should go, nor can I be bothered to trawl through 1.1.x, but if you want to, go nuts.

Biology Forums

When I try the first one, I get the error:

Fatal error: Function name must be a string in /home/biologyf/public_html/Sources/Load.php(2014) : eval()'d code on line 357

When I try the second one you posted, I get a table with an error saying:

Please try again. If you come back to this error screen, report the error to an administrator.

Advertisement: