MyBB-Plugins Forums
Printing Out Accounts w/ x Profile Field - Printable Version

+- MyBB-Plugins Forums (
+-- Forum: MyBB General Discussion (
+--- Forum: Coding Help (
+--- Thread: Printing Out Accounts w/ x Profile Field (/Thread-Printing-Out-Accounts-w-x-Profile-Field)

Printing Out Accounts w/ x Profile Field - Niki - 09-21-2018


I am attempting to create a script that prints out accounts with the input of x profile field. HOWEVER this profile field can vary and is edited by members to input anything they please. 

So for example the profile field is: 

Favorite Candy? Users can input anything from Snickers, Twix, Red Hot to even Zero Bars...

My main problem here is I know how to print out users IF I know what the profile field = (WHERE fid5 = 'Twix' for example). However this is a ranging answer so I cannot do a query for each possible candy out there. So what I'm trying to do instead is use a query that puts fid5 in its own sections each time.

User1, User2, User3 and so on.
User1, User2, User3 and so on.

Any help would be appreciated.


MANAGED TO GET THIS GOING, not sure how proper it is or if it would even do what I'm wanting buuuut:
PHP Code:
$Candy $db->query("
    ON "
.TABLE_PREFIX."userfields.ufid = ".TABLE_PREFIX."users.uid
    WHERE fid15  AND "
.TABLE_PREFIX."users.usergroup IN (19,18,11,9,10,3)
    ORDER BY fid15 ASC

However, the while part is where I'm thinking things are wrong. Because there would technically need to be a for each of the above script because it would print out category x, x, x in different sections. And THEN in those sections is where the while part would come in, which I do have:
PHP Code:
while($result=$db->fetch_array($Candy)) {
$userid $result['uid'];
$username format_name($result['username'], $result['usergroup'], $result['displaygroup']);
"\$CandyList .= \"".$templates->get("candy_entry")."\";");   

RE: Printing Out Accounts w/ x Profile Field - Diogo Parrinha - 09-24-2018


You could use the value as the key to an array and store it like this: (not valid PHP)
PHP Code:
$array[field_value][] = array(usernamegroupdisplaygroup); 

Then iterate the array with a foreach, for each table and then an inner foreach, for each user.