0

I am new to code Igniter framework, and I want to send querystring data, with $this->index(), function, how can i do this, I have done editing in config.php file, to accept query strings.

2 Answers 2

1

Your question is not clear at all. As an indication on how to work, though:

As it seems you already did, you must set to TRUE the "enable_query_string" config index:

$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';

As you see, you also have an index for the $_GET array where controllers and models will be placed. In order to build a url (which you must do manually, since the helpers work with uri segments) you can do something like:

index.php?c=mycontroller&m=mymethod&var1=var1

which maps to Mycontroller() controller class and Mymethod() class method, and works the same as for uri segments. In your methods, to retrieve the query string variables after the method, you can:

  1. use the $this->input->get('var1') input method to retrieve the query string part;
  2. use the "regular" $_GET array (which you have enabled by passing TRUE to the config index, as above), $_GET['var1']
  3. just pass the argument to the method (as in uri segments):

            function mymethod($var1)
            {
               echo $var1;
            {
    

"c" and "m" are default triggers, which you can obviously change to whatever you like (just set them in the 2 config indexes, of course).

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

Comments

0

In Code Igniter you may use $this->input->get() inside your controller functions. You can also use PHP's $_GET array. More information in the documentation at http://codeigniter.com/user_guide/libraries/input.html

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.