请帮助......似乎错误在
$ 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 :(得分:2)
这里使用$ row作为对象和数组(我假设你的错误消息来自哪里)。
foreach ($agent->result() as $row)
{
array_push($agentList, $row['AgentCode']);
$listAgent .= "<option value='".$row->AgentCode."'>".$row->Name."</option>";
}
更改为:
array_push($agentList, $row->AgentCode);