2013-12-19 100 views
0

控制器名稱:mother.php笨數據傳遞

控制器功能:

public function mother_dram_print() { 

    $mother = array(); 

    $mother['label'] = $this->load->view('mother/mother_dram', '', TRUE); 

    $data = array(

     'name_1' => $this->input->post('name_1'), 

     'size_1' => $this->input->post('size_1'), 

     'qty_1' => $this->input->post('qty_1') 

    ); 

    $data['label_print'] = $this->load->view('print_template', $mother, TRUE); 

    $this->load->view('home', $data); 
} 

查看文件名:mother_dram.php

查看文件:

<div class="moth-dram-label-main-container fix"> 

<?php 

for ($p1 = 1; $p1 <= $qty_1; $p1++) { 

    echo "<div class='moth-dram-label-wrapper fix'>"; 

    echo "<div class='moth-dram-name fix'>$name_1</div>"; 

    echo "<div class='moth-dram-ml'>$size_1</div>"; 

    echo "</div>"; 

} 

</div> 

注:當我從html表單數據提交的數據無法在mother_dram.php文件中查看。

+1

你沒有傳入任何數據給它,除非你直接從後面的數組中讀取數據,這是一種有趣的方法 – Rooster

回答

0

定義您$data你將它傳遞到$this->load->view('mother/mother_dram', $data, TRUE);

從代碼的風格之前,它看起來像你認爲$data沿着意見,只要你的地方定義它通過了,但是這是不是這樣的。