1

I'm working on a project using CodeIgniter, though I still a bit new on this PHP language framework. I need to create multiple variables URL in CodeIgniter like:

index.php?page=10&filter=voted

How do you write it in CI? I know if it's only one variable then it should be

index.php/page/10

If the URL contains two or more variables, should it be like this or not? And how do you retrieve them since it uses URI Segment?

index.php/page/10/filter/voted

Much thanks for the help!

1 Answer 1

1

you can get data using segment.

 $this->uri->segment(1);
 $this->uri->segment(2);
 $this->uri->segment(3);

or get all segment in array

$segment = $this->uri->segment_array();
print_r($segment);
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. How do you write the URL in Codeigniter? I need to put the url in an anchor link.
<a herf="<?php echo base_url() ?>index.php/page/<?php $yourvariable ?>/<?php $yourvariable ?>/<?php $yourvariable ?>"
Thanks. I think I know what to do know.

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.