Reputation: 3854
I am new to codeigniter i want to pass parameter as query string rather than segment i have seen other links but they didn't work. I want to use query string on this particular controller only. Below is the code that i am using:
<a href="<?=base_url()?>sample_qp/new_view/?id=<?=$a2?>">
<label class="fils-label">
Reload Page
</label>
</a>
and in controller:
public function new_view($id)
{ $id=$this->input->get('id');
$data['name']=$id;
$this->load->view('load_new_sample_view',$data);
}
i have set
$config['enable_query_strings'] = true; and $config['uri_protocol'] = "PATH_INFO"; but the issue is i am getting 404 page not found error.
Upvotes: 0
Views: 2886
Reputation: 38584
Method 01
Pass like this
<a href="<?=base_url()?>sample_qp/new_view/<?php echo $a2 ?>">
Make sure
short_url_tag
is on
In Controller
public function new_view($id)
{
if(empty($id))
{
echo "Invalid Token";
}
else{
echo($id);
}
}
Method 02
<a href="<?=base_url()?>index.php?c=sample_qp&m=new_view&id=<?=$a2?>">
In application/config.php
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
In Controller
$id = $this->input->get('id');
echo $id ;
Upvotes: 2