i have been trying without success to update multiple rows but each time i try i end up getting just a single row updated

**CONTROLLER**

```
public function update()
{
    $data['msg'] = '';
    $id = $_POST['reg_id'];
    $data['students'] = $this->test_model->getStudentData();
    if (isset($_POST['submit'])) {

            if (empty($id) || $id==0) {
                $data['msg'] = 'empty';
            } else {
                $userId = "'".implode("', ' ", $id)."'";

                $class =$this->input->post('class');

                $this->test_model->update($userId, $class);

            }

        } 
     $this->load->view('test', $data);
}

```

**MODEL**

```
public function update($where, $data){
    $this->db->query('UPDATE table SET data="'.$data.'" WHERE where IN('.$where.')');

 }

```

**view**

Sorry guys! i have been busy and just had the chance to go through your replies.

Here is the Form view

i have tried out all the solutions i got from you guys but i have not been able to get what i want. perhaps posting the form view would help you guys proffer a better solution 

```
<form action="<?php echo base_url() ?>test/update" method="POST" >
    <select name="class" id="">
        <option value="some value">some value</option>
        <option value="some value">some value</option>
        <option value="some value">some value</option>
        <option value="some value">some value</option>
        <option value="some value">some value</option>
    </select>
    <input type="submit" name="submit" value="submit">
    <table border="1">
        <thead>
            <tr>
                <th>REG. ID</th>
                <th>SURNAME</th>
                <th>FIRST NAME</th>
                <th>MIDDLE NAME</th>
                <th>CLASS</th>
            </tr>
        </thead>
        <tbody>

    <?php foreach ($students as $key): ?>
        <tr>
            <td><input type="checkbox" name="reg_id[]" value="<?php echo $key->reg_id ?>"><?php echo $key->reg_id ?></td>
            <td><?php echo $key->first_name ?></td>
            <td><?php echo $key->last_name ?></td>
            <td><?php echo $key->mid_name ?></td>
            <td><?php echo $key->class ?></td>
        </tr>
    <?php endforeach ?>
        </tbody>
    </table><br>

</form>

```