Welcome Guest, Not a member yet? Register   Sign In
error occurred in getting checkbox value
#1

(This post was last modified: 09-11-2018, 11:35 PM by kvanaraj. Edit Reason: post controller function )

Code:
<input type="checkbox" id="mycheck2" name="certid[]"        
     value="2"  class="cbx" <?php echo set_checkbox($student2['certid'],'1',
     $student2['certid']==2);?> >

Code:
A PHP Error was encountered
Severity: Notice

Message: Undefined offset: 1

Filename: controllers/Users.php

Line Number: 258

Backtrace:

File: C:\xampp\htdocs\transcript2\application\controllers\Users.php
Line: 258
Function: _error_handler

File: C:\xampp\htdocs\transcript2\index.php
Line: 315
Function: require_once
i am using 7 checkbox . first checkbox value correctly inserted. remaining checkboxes wrongly inserted.
Code:
controller
$certids = $this->input->post('certid');  //here you leave the [ ] out!
    $nocs = $this->input->post('noc');
    $result = array();
    foreach ($certids as $index=>$certid)
 {
       $result[] = $certid . '_' . $nocs[$index];
    }
    $date = new DateTime("now");
    $today = $date->format('Y-m-d');

    foreach($result as $value)
       {
       list($certid,$noc) = explode ('_',$value);
        $insert = array();
       $insert[] = array(
           'appno' => $appno,
           'regno' => $regno,
          'certid' => $certid,
             'noc' => $noc,
             'date' => $today
               );      
     
       $this->load->model('user_Model');
       $this->User_Model->studreginsert($insert);        
      }
Reply


Messages In This Thread
error occurred in getting checkbox value - by kvanaraj - 09-11-2018, 09:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB