-1

我一直在为这个挠头一段时间,

public function business()
    {
    $org = $this->session->userdata['logged_in']['org_id'];
    $query['org_details'] = $this->business_model->org_account($org);   
    $data = array('navigationContent' => $this->load->view('parts/p_navigation', array(), TRUE), 'mainContent' => $this->load->view('platform/business', array(), TRUE),);
    $this->load->view('templates/platform', $data, $query);
    }

Undefined variable: org_details在视图中产生此错误。我不知道为什么这不起作用

按要求编辑视图

<?php foreach($org_details as $row): ?>
        <fieldset>
        <div class="control-group">
        <label class="control-label">Platform Company ID:</label>
        <div class="controls">
        <input type="text" value="<?= $row['org_id']?>" disabled>
        </div>
        </div>
        <div class="control-group">
        <label class="control-label">ABN:</label>
        <div class="controls">
        <input type="text" value="<?= $row['org_abn']?>" disabled>
        </div>
        </div>
        <div class="control-group">
        <label class="control-label">Business Name:</label>
        <div class="controls">
        <input type="text" value="<?= $row['org_name']?>" disabled>
        </div>
        </div>
        <div class="control-group">
        <label class="control-label">Address:</label>
        <div class="controls">
        <input type="text" value="<?= $row['org_address']?>" disabled>
        </div>
        </div>
        <div class="control-group">
        <label class="control-label">Suburb:</label>
        <div class="controls">
        <input type="text" value="<?= $row['org_suburb']?>" disabled>
        </div>
        </div>
        <div class="control-group">
        <label class="control-label">State:</label>
        <div class="controls">
        <input type="text" value="<?= $row['org_state']?>" disabled>
        </div>
        </div>
        <div class="control-group">
        <label class="control-label">Post Code:</label>
        <div class="controls">
        <input type="text" value="<?= $row['org_pcode']?>" disabled>
        </div>
        </div>
        </fieldset>
<?php endforeach ?>

随着答案的出现,我已经更新了控制器,但结果仍然相同

4

3 回答 3

1

传入org_details数据数组,因为load->view只接受两个参数..

数据通过视图加载函数的第二个参数中的数组或对象从控制器传递到视图。

public function business()
{
   $org = $this->session->userdata['logged_in']['org_id'];
   $data['org_details'] = $this->business_model->org_account($org);   
   $data ['navigationContent']=$this->load->view('parts/p_navigation', array(), TRUE);
   $data['mainContent'] = $this->load->view('platform/business', array(), TRUE);
   $this->load->view('templates/platform', $data);
}

文档在这里

于 2013-03-13T06:01:13.337 回答
1

你能显示你的型号代码吗

    $this->business_model->org_account($org);   

可能对它进行建模而不返回结果();

于 2013-03-13T06:17:36.680 回答
-1
'mainContent' => $this->load->view('platform/business', $query, TRUE),);

这纯粹是侥幸!

于 2013-03-13T06:15:51.567 回答