Php 无法在控制器中获取id
我通过codeigniter中的锚标签发送IDPhp 无法在控制器中获取id,php,codeigniter,Php,Codeigniter,我通过codeigniter中的锚标签发送ID <a href='sectionEmpList/".$post_array['userSecId']."'> 但它显示了以下错误 遇到一个PHP错误 严重性:警告消息:缺少的参数1 Dashboard::SectionTempList()文件名:controllers/Dashboard.php行 编号:302回溯: 文件:D:\xampp\htdocs\mecon\application\controllers\Dashboard.
<a href='sectionEmpList/".$post_array['userSecId']."'>
但它显示了以下错误
遇到一个PHP错误
严重性:警告消息:缺少的参数1
Dashboard::SectionTempList()文件名:controllers/Dashboard.php行
编号:302回溯:
文件:D:\xampp\htdocs\mecon\application\controllers\Dashboard.php
行:302函数:\u错误\u处理程序
文件:D:\xampp\htdocs\mecon\index.php行:292函数:require\u一次
任何人都可以提出解决方案。试试这个:
<a href='sectionEmpList/'".$post_array['userSecId']."'>
您需要将id传递给视图
public function sectionEmpList(){
$data['secID'] = $this->session->userdata('id');
$this->load->view('some_view', $data);
}
然后观看
<a href="<?php echo base_url('your_controller/function/'. $secID);?>">
。和会话库
您可能还需要创建一个路由。您在应用程序/config/router.php下创建的路由器文件需要如下所示(这大致上是,根据您的设置可能有所不同)
$route['sectionEmpList/(:any)='] = 'YOURCONTROLLERHERE/sectionEmpList/$1';
这是由于单一报价。使用如下
$url = $post_array['userSecId'];
<a href='sectionEmpList/'.$url>
$url=$post_数组['userSecId'];
路由器文件是什么样子的?$id
没有传递到此函数是错误的意思。因此,url没有使用id生成,或者控制器没有正确处理它。url获取id,但它没有到达控制器我在会话中已经有id,我正在将该id从视图传递到函数在Controllery中,您没有解释我在问题Rout中添加了如下内容:$route['sectionEmpList/(:any)]=“dashboard/sectionEmpList”;
$url = $post_array['userSecId'];
<a href='sectionEmpList/'.$url>