MyBB Community Forums

Full Version: Printing Out Accounts w/ x Profile Field
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
UPDATED 10/22/2018: New information with where I've gotten thanks to the help of a friend suggesting to use SELECT DISTINCT to print out exact inputs from a field.

What I am attempting to do is create a script that prints out accounts with the input of x profile field. This profile field varies with input and can be edited quite often. So each profile field input is then printed out into its own section like so:
$Candy = $db->query("
    SELECT DISTINCT fid15
    FROM ".TABLE_PREFIX."userfields
    WHERE fid15 != ''
    ORDER BY fid15 ASC
");
while($result=$db->fetch_array($Candy)) {
    $type = $result['fid15'];
	eval("\$CandyList .= \"".$templates->get("candy_entry")."\";");
}

From here I am attempting to then also spit out the accounts in the while/result of $Candy ($CandyList template variable/candy_entry specific field template).
$Candy = $db->query("
    SELECT DISTINCT fid15
    FROM ".TABLE_PREFIX."userfields
    WHERE fid15 != ''
    ORDER BY fid15 ASC
");
while($result=$db->fetch_array($Candy)) {
    $type = $result['fid15'];
	eval("\$CandyList .= \"".$templates->get("candy_entry")."\";");
	
	$CandyU = $db->query("
        ?????????
    ");
	while($result=$db->fetch_array($CandyU)) {
        $userid = $result['uid'];
        $username = format_name($result['username'], $result['usergroup'], $result['displaygroup']);
        eval("\$CandyUsers .= \"".$templates->get("candy_users")."\";");   
    }
}

However everything I've tried to add in the $CandyU area just does not want to spit out the users with that particular field and quite frankly I'm lost. Help is very much appreciated!
Friendly bump.
Just another friendly bump, really curious on how I should accomplish this. I've wrote down steps and have searched the web for more information but I just do not think I understand enough to figure out where I need to go.

I've come to this conclusion with steps:
1) GRAB profile FID 15 inputs.
2) Spit all out.
3) When each one is spit out spit out usernames to all those with x selected.

So basically I want to grab FID 15 inputs (which is a textbox that many different things can be put into but some users have the same ones), I was to display each in their own sections (as if they were sections). Then from there I want to spit out all the accounts within each section.

Any help, pushes, links, etc. would be very much appreciated.