Simple Machines Community Forum

General Community => Scripting Help => Aiheen aloitti: TimUSA - joulukuu 22, 2007, 05:10:46 IP

Otsikko: Select - Form Element memberlist dropdown
Kirjoitti: TimUSA - joulukuu 22, 2007, 05:10:46 IP
I need to create a selection form element that is a drop down list for members in a certain member group array.

currently I am using the "action=findmember code":
<input type="text" name="name" id="name" value="', $context['name'], '" tabindex="', $context['tabindex'], '" size="40" /> <a href="', $scripturl, '?action=findmember;input=name;quote=1;sesc=', $context['session_id'], '" onclick="return reqWin(this.href, 350, 400);"><img src="', $settings['images_url'], '/icons/assist.gif" alt="', $txt['find_members'], '" /></a> <a href="', $scripturl, '?action=findmember;input=name;quote=1;sesc=', $context['session_id'], '" onclick="return reqWin(this.href, 350, 400);">', $txt['find_members'], '</a>

This does not work because when you it puts the Member name in quotes, amongst other problems later in the code.

any suggestions on how to do this?

Otsikko: Re: Select - Form Element memberlist dropdown
Kirjoitti: SleePy - joulukuu 30, 2007, 05:21:28 IP
What methods have you tried?
You would need to query all members in that group and output them. Depending on if you are using SSI.php or not will tell if you have to do this manually or if you could use a mod (for ssi)
Otsikko: Re: Select - Form Element memberlist dropdown
Kirjoitti: TimUSA - joulukuu 31, 2007, 11:06:22 AP
sorry I forgot to mark this as solved, but just for the record here is what i came up with:
$query = "SELECT `memberName` FROM `smf_members` WHERE `ID_GROUP` IN (1, 9, 10, 11, 13) ORDER BY `memberName`;";
$result = mysql_query($query);


echo'
<SELECT id="name" name="name" style="WIDTH: 160px" value ="';
echo '" />';

if(mysql_num_rows($result)) {
// we have at least one user, so show all users as options in select form
while($row = mysql_fetch_row($result))
{
print("<option value=\"$row[0]\">$row[0]</option>");
}
} else {
print("<option value=\"\">No user in this group</option>");
mysql_data_seek($result, 0);
}