Welcome Guest, Not a member yet? Register   Sign In
Update multiple users at once?
#2

[eluser]elverion[/eluser]
I'm not sure, but I think you can set the name of your dropdown to 'member_rank[]', which would then cause $this->input->post('member_rank') to be an array. That'll make it easy to run a for-loop to update each user.

Additionally, if you think you're going to have a lot of members being updated at once and want to limit your SQL queries, you should separate the users into different arrays. Each array will be a list of user IDs for each group, so one array for Founder, one for Captain, and so on. Use this in your query:
Code:
$this->db->where_in('id', $captains);
$this->db->set('member_rank', 'captain');
$this->db->update('clan_members');

$this->db->where_in('id', $members);
$this->db->set('member_rank', 'member');
$this->db->update('clan_members');

This would restrict your query count to the number of different ranks you have (~4), rather than running potentially hundreds of queries.


Messages In This Thread
Update multiple users at once? - by El Forum - 02-12-2012, 04:55 PM
Update multiple users at once? - by El Forum - 02-13-2012, 03:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB