MyBB Community Forums

Full Version: query fid of user in certain group?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I'm trying to get the list of everyone in our "Clan Member" group, which I have. Now can I grab a certain field that the user has filled out as well? I queried the group already, but I'm kinda lost on what I should do about the field.

Could someone with more knowledge help me out?
If you're the group leader then just goto UCP>Group Memberships.

On there it lists the groups you lead and a link with 'View Members'. Just click that.

If you're not the group leader and are the admin, just make yourself group leader and do it.
What?

I think your misunderstanding my question.

I'm making a separate page that lists all the members of the "Clan Member" group and instead of listing there Forum username, I want it to list the field that they filled out for there "Game Name".

I guess this would have been a much better way to say it before :p.
OH lol. That's clearer. That can be done, I assume you know some PHP?

You'll need to do an SQL query to lookup the userfields table.

So, assuming you have an array of the uid's of your clan group, just run a foreach loop and in the loop execute a query that looks up that user's answer to the field and output it.

Hope that helps a little bit.
I know SOME Toungue.

I am in the noob class, but I'm on my way up Big Grin

<?php

define("IN_MYBB", 1);
$templatelist = "adLog";
require_once './global.php';
require_once './rsslib.php';
 
add_breadcrumb("Adventurer's Log", "adLog.php");

$output = '';
// $usergroup['clan_member']
if ($mybb->user['usergroup'] == 7) {
    error_no_permission();
} else {

  $que =$db->query("SELECT * FROM mybb_users WHERE usergroup=8");
  //$dues =$db->query("SELECT * FROM mybb_profilefields");

  while ($arr =$db->fetch_array($que)) {
   foreach($arr as $user)   {
   $db->query("SELECT * FROM mybb_userfields"); 
          }
   }
  $output .= '<center><table width="100%">
       <tr colspan="2">
       <th colspan="2" class="thead"><div style="float:left; color:white;">The 
       Great Spiritz Adventurer\'s Log</div><div style="float:right;"><input
       type="text" value="Search players"><input type="button" value="Search"></th>
       </tr>
       <tr>
       <td style="width:50%;" class="trow2 page_content"><center>Choose a clan 
       member\'s name to view their Adventurer\'s Log.<br><br><div>';
	while($list = $db->fetch_array($user)) {
	   $output .= $list['5']."<br>\n";
	}
	$output .= '</div></center></td><td style="width:50%;" class="trow2 page_content">
	   <center>Search for a player\'s Adventurer\'s Log.<br><br></center></td>
       </tr>
       <tr colspan="2"><td colspan="2" class="tcat"></td></tr>
       </table></center>';    

    eval("\$adLog_home = \"".$templates->get("adLog"). "\";");
    output_page($adLog_home);
}

?>

That's what I have, and I know it doesn't work. I'm pretty sure it's close to what I need though.
That's what I was trying to do, but I keep getting some errors:

Warning [2] mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given - Line: 426 - File: inc/db_mysqli.php PHP 5.2.11 (Linux)
I've mashed something together that I think might work. I've not tested it and I've not removed anything from your code, only commented out bits.

<?php

define("IN_MYBB", 1);
$templatelist = "adLog";
require_once './global.php';
require_once './rsslib.php';

add_breadcrumb("Adventurer's Log", "adLog.php");

$output = '';
// $usergroup['clan_member']
if ($mybb->user['usergroup'] == 7) {
    error_no_permission();
} else {

    $que =$db->query("SELECT * FROM mybb_users WHERE usergroup=8");
    //$dues =$db->query("SELECT * FROM mybb_profilefields");

    /*while ($arr =$db->fetch_array($que)) {
        foreach($arr as $user) {
            $db->query("SELECT fid4 FROM mybb_userfields WHERE ufid =".$user['uid']);
        }
    }*/
    $output .= '<center><table width="100%">
       <tr colspan="2">
       <th colspan="2" class="thead"><div style="float:left; color:white;">The
       Great Spiritz Adventurer\'s Log</div><div style="float:right;"><input
       type="text" value="Search players"><input type="button" value="Search"></th>
       </tr>
       <tr>
       <td style="width:50%;" class="trow2 page_content"><center>Choose a clan
       member\'s name to view their Adventurer\'s Log.<br><br><div>';

    while ($arr =$db->fetch_array($que)) {
        foreach($arr as $user) {
            $user_answers = $db->query("SELECT fid4 FROM mybb_userfields WHERE ufid =".$user['uid']);
            while($tmp = $db->fetch_array($user_answers)){
                $output .= $tmp['fid4']."<br>\n";
            }
        }
    }

    /*while($list = $db->fetch_array($user)) {
        $output .= $list['5']."<br>\n";
    }*/

    $output .= '</div></center></td><td style="width:50%;" class="trow2 page_content">
       <center>Search for a player\'s Adventurer\'s Log.<br><br></center></td>
       </tr>
       <tr colspan="2"><td colspan="2" class="tcat"></td></tr>
       </table></center>';

    eval("\$adLog_home = \"".$templates->get("adLog"). "\";");
    output_page($adLog_home);
}

?>

You'll need to replace each instance of 'fid4' with 'fid(num)' where num is the fid of the custom field you're after. If that makes sense.

Let me know if this works. Smile
It makes plenty of sense.

Well, I'm not getting any errors finally :p but it doesn't show anything where the list should be, just spaces out like the names are invisible.
I think I cocked up.

Try replacing this:

foreach($arr as $user) {
            $user_answers = $db->query("SELECT fid4 FROM mybb_userfields WHERE ufid =".$user['uid']);
            while($tmp = $db->fetch_array($user_answers)){
                $output .= $tmp['fid4']."<br>\n";
            }
        }

With this:

foreach($arr as $user) {
            $user_answers = $db->query("SELECT fid4 FROM mybb_userfields WHERE ufid =".$user['uid']);
            while($tmp = $db->fetch_array($user_answers)){
foreach($tmp as $user){
$output .= $user['fid4']."<br>\n";
}
            }
        }

Obviously replacing fid4 again. Also run print_r on the arrays to make sure something is being outputted.
Yikes


MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
    1054 - Unknown column 'x' in 'where clause'
Query:
    SELECT fid4 FROM mybb_userfields WHERE ufid =x 
Where did x come from? Can you use print_r to print out $arr please?
Pages: 1 2 3