09-21-2018, 10:06 AM
Hello,
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.
Example:
Twix
User1, User2, User3 and so on.
Snickers
User1, User2, User3 and so on.
Any help would be appreciated.
Thanks!
MANAGED TO GET THIS GOING, not sure how proper it is or if it would even do what I'm wanting buuuut:
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:
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.
Example:
Twix
User1, User2, User3 and so on.
Snickers
User1, User2, User3 and so on.
Any help would be appreciated.
Thanks!
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("
SELECT * FROM ".TABLE_PREFIX."userfields
LEFT JOIN ".TABLE_PREFIX."users
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']);
eval("\$CandyList .= \"".$templates->get("candy_entry")."\";");
}