2017-05-03 68 views
0
http://localhost/cisbeadmin/index.php/conuser/edituser/.$row->$id_pegawai 

如何在CodeIgniter中从站点URL获取id? 这是我考虑的网页代码:如何从网站URL中查看页面

所有你不需要考虑直接获得的
<a href="<?php echo site_url('conuser/edituser/.$row->$id_pegawai'); ?> "> <i class="fa fa-edit"></i></a> 

回答

0

第一。你应该用控制器的方法得到它。在你的情况的方法名称edituser

这里有一个方法,你如何从URL获得ID:

// Make sure your segment possition is correct and place few lines of code in starting of your method edituser() 
$id = $this->uri->segment(3)) != '' && is_numeric($this->uri->segment(3)) && $this->uri->segment(3) > 0 ? $this->uri->segment(3) : false; 

// After getting $id check if it is false or having value in it 
if($id == false){ 
// If URL does not having id then it should show 404 error which is done by below line 
    show_404(); 
} 

// Pass $id value for view file same as we pass other values. 

希望我详细解释。如果您有任何问题,请告诉我。

0

与此

<a href="<?php echo site_url('conuser/edituser/'.$row->$id_pegawai); ?> "> <i class="fa fa-edit"></i></a> 

替换代码后,你可以在你的观点得到ID按下面的代码

$id_pegawai = $this->uri->segment(2);