0

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.

1

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Even easier is echo anchor("welcome/movie", $popmovies->movie_name)
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.