简体   繁体   中英

Remove ?variable_name= from url while working with query string in php codeigniter

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM