Welcome Guest, Not a member yet? Register   Sign In
SELECT selected CHECKBOX and update in selected row into DATABASE in Codeigniter
#1

i am new in CI,when i update this i did not get id, Please help me when i click on submit i got the id = 0, So please help me, i want update selected check box checked and update that record in Database



here is my VIEW:
   <form method="POST" action="<?php echo base_url() . "welcome/user_manager/" ?>">

                            <label>Select User</label>

                            <select name="user_role" id="user_role" onchange="calculate(this)">

                                <option>--Select User--</option>  

                                <?php
                                foreach ($roll_get as $roll) {
                                    ?>
                                    <option value="<?php echo $roll->user_id; ?>" id="<?php echo $roll->user_id; ?>"><?php echo $roll->full_name; ?></option>
                                    <?php
                                }
                                ?>
                            </select><br>
                            <input id="checkAll" type="button" value="Check All">
                               <div class="button">
                            <?php
                            foreach ($listMenuLevel1 as $menu1) {
                                ?>

                                <div id="checkboxlist">

                                    <li class="treeview">
                                        <input type="checkbox" name="sample[]" value="0"/> <a href="<?php echo base_url(); ?>welcome">
                                            <span><?php echo $menu1->category_name; ?></span>
                                        </a>
                                        <?php if (count($this->main_model->listchildMenus($menu1->category_id)) > 0) { ?>
                                            <ul class="treeview-menu">
                                                <?php foreach ($this->main_model->listchildMenus($menu1->category_id) as $menu2) { ?>
                                                    <li ><input type="checkbox" name="sample[]" value="0"/><a href="<?php echo base_url(); ?><?php echo $menu2->category_link; ?>"><?php echo $menu2->category_name; ?></a></li>
                                                    <ul>
                                                        <?php foreach ($this->main_model->listchildMenus($menu2->category_id) as $menu3) { ?>
                                                            <li><input type="checkbox" name="sample[]" value="0"/><a href="<?php echo base_url(); ?><?php echo $menu3->category_link; ?>"><?php echo $menu3->category_name; ?></a></li>
                                                        <?php } ?>
                                                    </ul>


                                                <?php } ?>
                                            </ul>
                                        <?php } ?>

                                    </li>
                                </div>
                                <?php
                            }
                            ?>



                            <input type="submit" class="btn btn-primary" value="Save">
                        </form>



Here Is My Controller:


public function user_manager() {


        $user_id = $this->input->post('user_role');
        $this->main_model->check_update($user_id);
}


Here is My Model:
 public function check_update($user_id){
      
        $data   = array();
        if($this->input->post('sample')){
            $ans    = $this->input->post('sample');
            foreach($ans as $each){
                if(isset($each) && $each != ""){
                    $data['user_rights'] = '1';
                    $this->db->where('user_id', $each)->update('user_registration', $data);
                }
            }
        }
    }
Reply


Messages In This Thread
SELECT selected CHECKBOX and update in selected row into DATABASE in Codeigniter - by jaydevvara - 07-18-2018, 09:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB