0

尝试制作一些动态组合框并发现一些麻烦..这是代码

控制器

$this->load->model('main_model');
$data['sales'] = $this->main_model->getSales();
$this->load->view('dashboard_view',$data);

该模型

    $this->db->select('*');
    $this->db->from('salesman');
    $this->db->where('cabangid',$cabangid);
    $this->db->order_by('salesmanid','ASC');
    $array_keys_values = $this->db->get();     
foreach ($array_keys_values->result() as $row)
    {
        $result[0]= '- sales-';
        $result[$row->salesmanid]= $row->description;
    }

    return $result;

风景

<div id="sales" style="width:250px;float:left;">
sales: <br/>
<?php
    echo form_dropdown("salesmanid",$sales,"","id='salesmanid'");
?>

错误是这样的..

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: sales

Filename: views/dashboard_view.php

Line Number: 14

A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: helpers/form_helper.php

Line Number: 331

任何帮助将不胜感激..:D

4

0 回答 0