How to display multiple views on different pages in codeigniter

Hi guys, I'm new to codeigniter, I want to display multi-user view on different pages .. I create a page where I create an edit button, I want that when I click the edit button, I iterate on another page. I can do this., Help in pls here is my code:

class Edit extends CI_Controller { function __construct() { parent::__construct(); } function edit() { $this->load->helper('url'); if($this->input->post('edit') == True) { redirect('edit'); } } } 
+4
source share
2 answers

View 1: (where your link is)

 <?php echo anchor('Edit/edit', 'Edit Value'); // Here Edit is your controller and edit is the function name. ?> 

And in the Edit editor, change it like this:

 class Edit extends CI_Controller { function __construct() { parent::__construct(); } function edit() { $this->load->helper('url'); if($this->input->post('edit') == True) { //redirect('edit'); //Do not use this as this line will call the same function again. $this->load->view('edit_view'); // where edit_view.php is present in your views directory. } } } 

Hope this helps.

+1
source

The button will be displayed, which means that when you click on the button on the screen, it should be redirected to another page (view):

use binding to this in the view:

  <?php echo anchor('controller_name/function_name', 'acnchor_name'); ?> <?php echo anchor('Edit/edit', 'edit'); ?> 

where edit should be the name of the function and view.

Now a click-to-click link will be displayed, it will be redirected to edit the view.

I hope you will be helped!

+1
source

All Articles