I have array id like this,
Array ( [0] => 1013 [1] => 1012 [2] => 1011 [3] => 1010 )
I want to update my table user by those id, here my controller code
public function index()
{
$id = $this->input->post('check_list');
print_r($id); // just try to check output value
$this->template->load('v_t','v_e', $data);
}
thanks.
Thank for all, I just found my answer, here my controller code for update sql by array id
public function update()
{
$this->load->database();
foreach($_POST['check_list'] as $checkbox) {
$data = array(
'STATS' => 'A');
$this->db->where('ID', $checkbox);
$this->db->update('USERS', $data);
}
You can use where_in like below
$this->db->where_in("id", $ids);
$this->db->update("tableName", $data);
Change above code with your table name and column names.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.