2016-03-07 81 views
0

請幫助...這似乎錯誤是在致命錯誤:在線路不能使用類型爲stdClass的對象作爲數組33

$agentList = array();

我只是想回響在我看來

列表請幫助...請幫助...請幫助...

$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); 
+0

嘗試'result_array()',而不是'結果()' – user4419336

回答

2

在這裏,您使用$行作爲對象和數組(這是您的錯誤消息來自我假設)。

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

更改爲:

array_push($agentList, $row->AgentCode); 
+0

感謝先生...... :) –

相關問題