2014-02-09 92 views
1

不工作我有這個功能** **控制器發送數據從控制器查看笨

function smsreq() 
    { 
     $this->form_validation->set_rules('amount', 'Amount', 'trim|required|xss_clean'); 
     $this->form_validation->set_rules('mobileNo', 'Mobile Number', 'trim|required|xss_clean'); 
      if ($this->form_validation->run()) { 
       echo "validated"; 
      } else { 
      $data = "<div>TEST</div>" ; 
      $this->load->view('dashboard',$data); 
      } 
    } 

,並在** **觀點

<?php echo $data ; ?> 

但當視圖, 'dashboard'is loaded this顯示

A PHP Error was encountered 

Severity: Notice 

Message: Undefined variable: data 

Filename: views/dashboard.php 

Line Number: 190 

爲什麼不能通過該值?

回答

1

您必須從控制器傳遞數組作爲查看。

$data["data"] = "<div>TEST</div>" ;