Reputation: 75
I am Working At Codeigniter PHP. And Trying To Pass Some Data From View To Controller With The The Help Of Query String, As I Don't Use Any Form.
As Following:
<a href="welcome/movie?name=<?php echo $popmovies->movie_name;?>" >GO</a>
But Through Query String My URL Is Looking So Garbage Type. This Is What I Currently Have.
http://subs.nexthon.com/welcome/movie?name=Avangers
This Is What I Want To Have
http://subs.nexthon.com/welcome/movie/Avangers
How Can I Do This.
Upvotes: 0
Views: 136
Reputation: 9707
Your anchor should be like this :
<a href="<?=site_url('welcome/movie/'.$popmovies->movie_name);?>" >GO</a>
Access like this in controller :
public function movie($movie_name)
{
echo $movie_name;
/*output : Avangers*/
}
for more : https://www.codeigniter.com/user_guide/general/controllers.html#passing-uri-segments-to-your-methods
Upvotes: 1
Reputation: 5322
You can directly pass your data in URL
EXAMPLE FROM CODEIGNITER DOC
http://example.com/news/local/metro/crime_is_up
The segment numbers would be this:
1.news 2.local 3.metro 4.crime_is_up
You can get data by using segment()
$product_id = $this->uri->segment(3);
For mode detail please read Codeigniter URL
Upvotes: 0