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

どのように私はCodeIgniterの中で、サイトのURLからIDを取得することができますか? これは、ビューページでの私のコードです:どのビューページでサイトのURLからIDを取得する

<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_pegawai = $this->uri->segment(2); 
以下のとおりに、あなたのビューでIDを取得することができた後でコードを置き換え
関連する問題