我想從URL中獲取'id'以刪除特定選定的產品。我已經使用$this->uri->segment(3)
,但沒有從URL獲得任何價值。雖然我可以在我的網址中看到'product_id'。如何從codeigniter中的URL獲取ID?
如果我使用$this->url->segment(2)
它給了我第二個值表單URL,但我無法獲得產品ID。 以下是我的代碼。請引導我。
VIEW
echo "<a href='delete_controller?product_id=$product_id'>";
echo $name;
echo "</a>";
當我在$名稱點擊以下網址正在生成。
http://localhost/designs2/index.php/products_controller/delete_controller?product_id=70
控制器
public function delete_controller()
{
echo $product_id =$this->uri->segment(3);
echo "Taha";
$this->load->view('delete_confirmation');
}
謝謝!我從標記中刪除了'?product_id =',它給了我一個完美的URL。 –