Shan Perera
Shan Perera

Reputation: 5

How to send Data form view to controller through URL in codeigniter and how i get data in controller

How to send Data form view to controller through URL in codeigniter and how I get data in controller?

<div class="col-md-3 col-md-3-text"> <div class="classWithPad"><img src="<?php echo base_url(); echo 'assets/img/'; echo $title[$i]->image; ?>"/> <?php $id = $title[$i]->category_id; ?>
             <div class="title_banner"><a href="<?php echo site_url('Welcome/category','' ) ?>" class="mhover"><?php echo $title[$i]->category_name; ?></a></div>
            </div>
      </div>

send like this

Upvotes: 0

Views: 3301

Answers (1)

Narendrasingh Sisodia
Narendrasingh Sisodia

Reputation: 21437

You have to use $_GET[] method of php:

<a href="<?php echo base_url()?>your_Controller/your_function?id=1">My Data</a>

This will redirect to your controller where you had your function and within your_function you have to use $_GET['id'] as

function your_function() {
    $id = $this->input->get('id');
}

Upvotes: 1

Related Questions