Search code examples
phpcodeigniter

In codeigniter i am send a php variable from view page to controller through the <a> tag, but i can't display value in controller page


this is my view page code

<td><a href="<?php echo site_url("Customer/viewpatient/?id=".$id); ?>" ><button type="button" name="admit" class="btn btn-danger" data-toggle="modal" id="btnViewCust">Admit</button></a></td>

this is my controller function

public function viewpatient()
{

        $data['id'] = $this->input->post('id');
        echo $data['id'];

}

Solution

  • Use this $this->input->get()

       public function viewpatient()
        {
    
        $data['id'] = $this->input->get('id');
        echo $data['id'];
    
       }