I'm trying to do is when i clicked my specific product, instead of the id of my product would appear in my url, i want to put the name of the product . what i did today is base_url/controller/method/id
i want to do is base_url/controller/method/product-name or base_url/controller/method/product_name
but in my code what happened is in my product name all the spaces is occupied by %20 what should i do to replace the %20 by either underscore or dash or whatever safe way to call the product name in url.
and whatever i get on that $name(product_name) i will pass it to my model.
MY CONTROLLER
public function details($name){
$prod_row = $this->PromoModel->getpromorow($name);
$data['promodetail'] = $prod_row;
$data['promo'] = $this->PromoModel->get_promo();
$data['message']= "<h1> NO PROMOS AVAILABLE</h1>";
$this->load->view('include/header',$data);
$this->load->view('include/nav');
$this->load->view('promo/PromoDetail', $data);
$this->load->view('include/footer');
}
MY MODEL
public function getpromorow($name) {
$this->db->where('name', $name);
$query = $this->db->get('promo');
return $query->row();
}
public function get_promo(){
$query = $this->db->get('promo');
return $query->result();
}
MY VIEW
<a href="<?= base_url(). 'promos/details/' . $promo_row->name ?>"> </a>
str_replace(' ', '_', $promo_row->name)ORstr_replace(' ', '-', $promo_row->name), do this before putting it in the url.urlencode()here.