0

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.

1
  • What did you achieve so far? Commented Feb 27, 2018 at 3:12

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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);

    }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.