Thanks Shrike, that's got me on the right path but I'm having problems still with the code.
Could someone take a look to see if it's something blazingly obvious that I've done wrong?.
In the template file I have:
</tr>
<!-- BEGIN rows -->
<tr>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="299"><span class="gen">{guilds_approve_list.rows.APPROVE_ROW}</span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_NAME}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_LEVEL}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_HP}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_MP}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_WINS}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_DEFEATS}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_FLEES}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">{guilds_approve_list.rows.APPROVE_HOPS}</a></span></td>
<td class="{guilds_approve_list.rows.ROW_CLASS}" align="center" width="300"><span class="gen">
<input type="hidden" name="guild_id" value="{GUILD_ID}" />
<input type="checkbox" name="approve_box[]" value="{APPROVE_ID}" /></td>
</tr>
<!-- END rows -->
<tr>
<td class="catBottom" align="center" colspan="10">{ACTION_SELECT} <input class="mainoption" type="submit" value="{L_SUBMIT}" /></td>
</tr>
</table>
And for the main code I have:
case 'guilds_approve_list' :
$guild_id = intval($HTTP_GET_VARS['guild_id']);
$template->assign_block_vars('guilds_approve_list' , array());
// Grab details from Guilds table...
$sql = " SELECT * FROM " . ADR_CHARACTERS_TABLE . "
LEFT JOIN " . ADR_GUILDS_TABLE . "
ON " . ADR_CHARACTERS_TABLE . ".character_guild_approval = " . ADR_GUILDS_TABLE . ".guild_id
WHERE " . ADR_GUILDS_TABLE . ".guild_id = $guild_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query Guild table for Rank 3', '', __LINE__, __FILE__, $sql);
}
$action_select = '<select name="mode">';
$action_select .= '<option value = "">' . $lang['Adr_items_select_action'] . '</option>';
$action_select .= '<option value = "guilds_approve_yes">' . $lang['Adr_guilds_approve_yes'] . '</option>';
$action_select .= '<option value = "guilds_approve_no">' . $lang['Adr_guilds_approve_no'] . '</option>';
$action_select .= '</select>';
if ( $guilds_table = $db->sql_fetchrow($result) )
{
$i = 0;
do
{
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('guilds_approve_list.rows', array(
"APPROVE_ROW" => $i + 1,
"ROW_CLASS" => $row_class,
"APPROVE_ID" => $guilds_table['character_id'],
"APPROVE_NAME" => $guilds_table['character_name'],
"APPROVE_LEVEL" => $guilds_table['character_level'],
"APPROVE_HP" => $guilds_table['character_hp_max'],
"APPROVE_MP" => $guilds_table['character_mp_max'],
"APPROVE_WINS" => $guilds_table['character_victories'],
"APPROVE_DEFEATS" => $guilds_table['character_defeats'],
"APPROVE_FLEES" => $guilds_table['character_flees'],
"APPROVE_HOPS" => $guilds_table['character_guild_hops'],
));
$i++;
}
while ( $guilds_table = $db->sql_fetchrow($result) );
}
$template->assign_vars(array(
'L_APPROVE_ROW' => $lang['Adr_guilds_position'],
'ACTION_SELECT' => $action_select,
'GUILD_ID' => $guild_id,
'L_SUBMIT' => $lang['Adr_guilds_submit'],
'U_SUBMIT' => append_sid("adr_guilds.$phpEx?mode=$action_select&sub_mode=&guild_id=$guild_id&approve_box=$approve_id"),
));
break;
case 'guilds_approve_yes' :
$guild_id = intval($HTTP_GET_VARS['guild_id']);
$approve_id = ( isset($HTTP_POST_VARS['approve_box']) ) ? $HTTP_POST_VARS['approve_box'] : array();
if ( count($approve_id) > 0 )
{
for($i = 0; $i < count($approve_id); $i++)
{
$approved_user_id = $approve_id[$i];
// Remove Guilds details from Character table...
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_guild_auth_id = 0 ,
character_guild_approval = 0 ,
character_guild_id = $guild_id
WHERE character_id = $approved_user_id ";
if( !$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update approved characters',"", __LINE__, __FILE__, $sql);
}
}
}
adr_update_posters_infos();
adr_previous( Adr_guilds_approve_list_approve , adr_guilds , '' );
break;
I think the problem is that each users id isn't passing through to the 'guilds_approve_yes' case.
Any help would be great, thanks. 🙂