[英]How to pass the value from view to controller
这是我的控制器代码
$data['query']= $this->webpages->get_where_custom('parent_id',0);
// i will get $id from view
$data['query']=$this->webpages->get_where_custom('parent_id',$id);
$this->load->view-(template,$data);
在视图代码中,我将向控制器发送$ id,但显示未定义的变量'id'
<?php
foreach($query->result() as $row){
$id=$row->id; // how to send this $id to my controller
$page_url=$row->page_url;
$parent_id=$row->parent_id;
$page_headline=$row->page_headline;
foreach($query->result() as $row){
$page_url=$row->page_url;
$page_headline=$row->page_headline;
?>
echo $page headline;
}
}
安装:
$this->load->view-(template,$data);
尝试:
$this->load->view(template,$data);
您的代码如下所示
$this->load->view('template',$data);
这是因为您没有在查询的数据中放入$ id
因此<?php print_r($query); ?>
<?php print_r($query); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.