2017-05-03 29 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);