未定义偏移量:1(使用复选框)

时间:2018-09-12 04:51:48

标签: php codeigniter

重新填充复选框的值时发生

错误。 重新填充并在表单中进行更改后,第一次正确存储复选框值将返回错误 我选中复选框

 <?php foreach($getcert1 as $student1){ 
                  ?>
              <td width="50px" align="center">1</td>
              <td>Transcripts  & Degree Certificate Attestation</td>
              <td align="center">
                <input type="checkbox" id="mycheck1" name="certid[]"        
                value="1" class="cbx" <?php echo set_checkbox($student1['certid'],'1', 
                $student1['certid']==1);?> > 
                </td>
              <td> 500 </td>
             <td> <input type="number" id="primaryincome1"  min="1"  max="999" name="noc[]" 
             value="<?php echo (!isset($student1['noc'])) ? 0 : $student1['noc'] ?>"
           disabled> </td>
              <div class="col-xs-2">
              <td ><input type="text" id="totalamountremaining1"  name="txt" class="text-right" value="<?php echo (!isset($student1['paid'])) ? 0 : $student1['paid'] ?>"  size="5"></td>
          </div>   
            </tr>
          <?php } ?>

第二个复选框

<?php foreach($getcert2 as $student2){ 
          echo '<pre>';
            print_r($student2);
            echo '</pre>';

                ?>
            <td width="50px" align="center">2</td>
            <td>WES form Authorization by University</td>
            <td align="center">
              <input type="checkbox" id="mycheck2" name="certid[]"        
              value="2"  class="cbx" <?php echo set_checkbox($student2['certid'],'1', 
              $student2['certid']==2);?> > 
              </td>
            <td> 500 </td>
           <td> <input type="number" id="primaryincome2"  min="1"  max="999" name="noc[]" 
           value="<?php echo (!isset($student2['noc'])) ? 0 : $student2['noc'] ?>"
         disabled> </td>
            <div class="col-xs-2">
            <td ><input type="text" id="totalamountremaining2"  name="txt" class="text-right" value="<?php echo (!isset($student2['paid'])) ? 0 : $student2['paid'] ?>"  size="5"></td>
        </div>   
          </tr>
        <?php } ?>

我的代码中缺少什么? 错误

  

遇到PHP错误严重性:通知消息:未定义   偏移量:1文件名:controllers / Users.php行号:258

     

回溯:

     

文件:C:\ xampp \ htdocs \ transcript2 \ application \ controllers \ Users.php   行:258功能:_error_handler

     

文件:C:\ xampp \ htdocs \ transcript2 \ index.php行:315功能:   require_once

控制器

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

foreach ($certids as $index=>$certid) 
  {
    $result[] = $certid . '_' . $nocs[$index];
  }

   echo '<pre>';
    print_r($result);
   echo '</pre>';
    Array
 (
  [0] => 1_2
  [1] => 2_2
  [2] => 3_2
  [3] => 4_2
  [4] => 5_2
  [5] => 6_
  [6] => 7_
     )

0 个答案:

没有答案