0

Please help... it seems the error is in

$agentList = array();

i just want to echo the list in my view

Please help... Please help... Please help...

$this->load->model('home_model');
        $agent= $this->home_model->getAgent($data['userID']);
        $agentList = array();
        $listAgent = '';

        if($agent !== FALSE)
        {
            foreach ($agent->result() as $row)
            {
                array_push($agentList, $row['AgentCode']);
                $listAgent .= "<option value='".$row->AgentCode."'>".$row->Name."</option>";
            }
        }

        $listSchool = $this->home_model->getAllSchool($agentList);
        $listTD = '';
        if($listSchool !== FALSE)
        {
            foreach ($listSchool->result() as $row)
            {
                $address = $row->Address." ".$row->Address2;
                $listTD .=  "<tr>
                                <td class='schoolCode' data-comp='".$row->CompanyName."' data-kpID='".$row->KeyPersonID."'>".$row->No_."</td>
                                <td>".$row->Name."</td>
                                <td>".$address."</td>
                                <td class='schoolCode2'>".$row->SecondaryCode."</td>
                                <td>".$row->SegmentName."</td>
                            </tr>";
            }
        }

        $data['returnData'] = array("listAgent" => $listAgent, "listTD" => $listTD);
        $this->load->view('home',$data);
1
  • try result_array() instead of result() Commented Mar 7, 2016 at 4:11

1 Answer 1

2

Here you are using $row as both an object and an array (which is where your error message comes from I assume).

foreach ($agent->result() as $row)
        {
            array_push($agentList, $row['AgentCode']);
            $listAgent .= "<option value='".$row->AgentCode."'>".$row->Name."</option>";
        }

Change to:

array_push($agentList, $row->AgentCode);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.