Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:05:04+00:00 2026-05-26T11:05:04+00:00

My problem is, I key in the sibling details in the first row textboxs

  • 0

My problem is, I key in the sibling details in the first row textboxs and i select the check box no error display. If i didn’t select the checkbox its display the below error. Can you give some idea? i am new for CodeIgniter.

I got error message: (How i can solve the error)

A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
Filename: controllers/registration.php
Line Number: 288

Below my Code:

foreach($querystud_frm->result() as $row)
        {
            echo "<tr><td>".$i.")</td>";
            $data=array('name'=>'s_sibling_name[]','class'=>'textbox','value'=>$row->s_sibling_name,'style'=>'text-transform:uppercase;');
            echo "<td >".form_input($data)."</td>";
            $data=array('name'=>'s_sibling_nric[]','class'=>'textbox','value'=>$row->s_sibling_nric,'style'=>'text-transform:uppercase;');
            echo "<td >".form_input($data)."</td>";
            $sib_dob=date('d-m-Y',strtotime(trim($row->s_sibling_dob)));
            $data=array('name'=>'s_sibling_dob[]','class'=>'textbox','value'=>$sib_dob,'style'=>'text-transform:uppercase;');
            echo "<td >".form_input($data)."</td>";
            $data=array('name'=>'s_sibling_relation[]','class'=>'textbox','value'=>$row->s_sibling_relation,'style'=>'text-transform:uppercase;');
            echo "<td >".form_input($data)."</td>";
            $data=array('name'=>'s_sibling_occupation[]','class'=>'textbox','value'=>$row->s_sibling_occupation,'style'=>'text-transform:uppercase;');
            echo "<td >".form_input($data)."</td>";
            $data=array('name'=>'s_sibling_income[]','class'=>'textbox','value'=>$row->s_sibling_income,'style'=>'text-transform:uppercase;');
            echo "<td >".form_input($data)."</td>";
                $sib_yes = $row->s_sibling_yes;
            echo $sib_yes;
            if($sib_yes == 'YES')
            {
            $data= array('name' => 's_sibling_yes[]', 'id' => 's_sibling_yes', 'value' => 'YES', 'checked' => TRUE);
            echo "<td >".form_checkbox($data)."</td>";
            }
            else
            {
            $data= array('name' => 's_sibling_yes[]', 'id' => 's_sibling_yes', 'value' => 'NO', 'checked' => FALSE);
            echo "<td >".form_checkbox($data)."</td>";
            }

    echo "</tr>"; 
                $i++;
        }

        if($i<10)
        {
            $var=array("s_sibling_name","s_sibling_nric","s_sibling_dob","s_sibling_relation","s_sibling_occupation","s_sibling_income");
            for($j=$i;$j<=10;$j++)
            {
                echo "<tr><td>".$j.")</td>";
                foreach($var as $value)
                {
                    $value=$value.'[]';
                $data_val=array('name'=>$value,'class'=>'textbox','value'=>'','style'=>'text-transform:uppercase;');
                echo "<td>".form_input($data_val)."</td>";
                }
            if($sib_yes == 'YES')
            {
            $data= array('name' => 's_sibling_yes[]', 'id' => 's_sibling_yes', 'value' => 'YES', 'checked' => TRUE);
            echo "<td >".form_checkbox($data)."</td>";
            }
            else
            {
            $data= array('name' => 's_sibling_yes[]', 'id' => 's_sibling_yes', 'value' => 'NO', 'checked' => FALSE);
            echo "<td >".form_checkbox($data)."</td>";
            }

    echo "</tr>"; 
            }
            unset($var);
        }

        $querystud_frm->free_result();
    }
    else 
    {
        $var=array("s_sibling_name","s_sibling_nric","s_sibling_dob","s_sibling_relation","s_sibling_occupation","s_sibling_income");
        $var_sib=array("s_sibling_yes");            
        for($i=1;$i<=10;$i++)
        {
            echo "<tr><td>".$i.")</td>";
            foreach($var as $value)
            {
                $name=$value.'[]';  
                $data=array('name'=>$name,'class'=>'textbox','value'=>'','style'=>'text-transform:uppercase;');
                echo "<td >".form_input($data)."</td>";
            }
                $data= array('name' => 's_sibling_yes[]', 'id' => 's_sibling_yes', 'value' => 'YES', 'checked' => FALSE);
                echo "<td >".form_checkbox($data)."</td>";
    echo "</tr>"; 

        }
        unset($var,$i,$data,$var_sib);
    }

controller/registration.php

            if($this->input->post('siblingsfrm'))
        {
            $this->data['nric']=$this->input->post('s_nric');
            //echo $this->input->post('name');
            $name=$this->input->post('s_sibling_name');
            $nric=$this->input->post('s_sibling_nric');
            $dob=$this->input->post('s_sibling_dob');
            //$dob=strtotime($dob);
            //$dob=date('Y-m-d',strtotime($dob));
            $relation=$this->input->post('s_sibling_relation');
            $occupation=$this->input->post('s_sibling_occupation');
            $income=$this->input->post('s_sibling_income');
            $sib_yes=$this->input->post('s_sibling_yes');
            $sib_id=$this->input->post('s_sibling_id');
            //print_r($sib_id);
            //print_r($name);
            //exit();
            //$this->load->helper('date');
            for($i=0;$i<count($name);$i++)
            {
                if($name[$i]!='')
                {
                    $income[$i]=trim($income[$i]);
                    if($income[$i]=='')
                    $income[$i]=0;
                    if($sib_yes[$i]!= 'YES')
                    $sib_yes[$i]='NO';
                    $date=date('Y-m-d',strtotime(trim($dob[$i])));
                $insert_values=array('s_nric'=>$this->data['nric'],'s_sibling_name'=>strtoupper(trim($name[$i])),
                                    's_sibling_nric'=>strtoupper(trim($nric[$i])),'s_sibling_dob'=>$date,
                                    's_sibling_relation'=>strtoupper(trim($relation[$i])),
                                    's_sibling_occupation'=>strtoupper(trim($occupation[$i])),
                                    's_sibling_income'=>strtoupper(trim($income[$i])),
                                    's_sibling_yes'=>trim($sib_yes[$i]));
                if(is_array($sib_id) && isset($sib_id[$i]) )
                {
                    $where=array('s_sibling_id'=>$sib_id[$i]);
                    $this->db->update('si_student_siblings',$insert_values,$where);
                }
                else
                {
                    //print_r($insert_values);
                    $this->db->insert('si_student_siblings',$insert_values);
                }
                }
            }
            $this->data['level']=7;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:05:04+00:00Added an answer on May 26, 2026 at 11:05 am

    The problem is that if a checkbox wasn’t checked, it won’t send any data at all to the server. So, this line of code…

    $name=$this->input->post('s_sibling_name');
    

    …will actually set the $name variable to FALSE (see $this->input->post() documentation in the guide)

    Thus, the first time through your loop, your code is looking for the array item at $name[0], when in fact $name is not even an array, it’s FALSE.

    You could surround your for loop with an if/else statement to solve this problem (not the most elegant solution, but it would work):

    if (is_array($name) && count($name) > 0)
    {
      for($i=0;$i<count($name);$i++)
      {
        if($name[$i]!='')
          //etcetera...
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with foreign key in mysql.I'm trying to insert a row
The Problem I want to press a key when I have a line highlighted
I am facing the problem that I cannot properly map my foreign key table
I've solved my previos problem of converting XML RSA private key to PEM file,
So here is my problem. I want to store 2-tuple (key, val) and want
I've got a problem with foreign key. This is my DB structure (simplified): Table
Problem: In MS Access you can hold the shift key when opening a database
I have a problem that I believe I need to use grouping using xsl:key
We have a couple of mirrored SQL Server databases. My first problem - the
Given two tables: (incoming greatly reduced/simplified example that exhibits the key problem) app_data represents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.