php - 如何将值从 View 传递到 Controller

标签 php mysql codeigniter

这是我的 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);

在 View 代码中,我将发送 $id 到 Controller ,但它显示 undefined variable “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);

关于php - 如何将值从 View 传递到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21428709/

相关文章:

php - 方法返回值不一致

php - 警告 : ldap_start_tls() [function. ldap-start-tls]:无法启动 TLS:服务器不可用

php - 在多值行中插入一个值

php - 用于存储 php 代码的最佳 mysql 数据类型?

php - 设置 CodeIgniter 以显示在 http ://localhost/ci/

javascript - 如何通过ajax将隐藏字段值传递给codeigniter Controller

php - DKIM 仅适用于短消息

PHP/MySQL 在某些查询中没有返回结果

php - 数据表显示第二个表但没有反应

php - codeigniter - 在 Controller 中使用助手不起作用