Codeigniter passing data from controller to view
Ah, the $data
array's keys are converted into variables: try var_dump($title);
for example.
EDIT: this is done using extract.
Codeigniter passing data controller to view
To load a view you should do like this.
$this->load->view("filename");
If you want to pass data to view, you should do like this.
$this->load->view("filename",$data);
$data
should have all parameters which you want to print in view.
The syntax goes like this.
$this->load->view("filename","data to view","Returning views as data(true / false");
If third parameter is true, view will come as data. It will not go to browser as output.
Edit:
Change
$this->load->view('print_view',$insertdata);
to
$data['insertdata'] = $insertdata;
$this->load->view('print_view',$data);
For more info, check this link
Codeigniter sending data from controller to view
I have tried lots of deferent things to fix this. I have no idea why this keeps happening, but finally, I fixed my problem using ajax
$(document).ready(function(){
$.ajax({
url:'<?php echo base_url('admin/report/index'); ?>',
success:function(data){
$('#same').html(data);
},
error: function(){
alert('Error');
}
});
Passing Data from View to Controller (codeigniter)
You could simply us Uri segmen, just like this:
your View Code for href.
<a href="<?php echo base_url() ?>wapi/details/6";
And to GET the value you passed from view to controller
You should do something like this in your controller
public function details(){
$data_id = $this->uri->segment(3); //this where you get you value from your link
...//rest of your code
}
Related Topics
How to Change Maximum Number of Post Variable in PHP
PHP Pdo Prepared Statement - MySQL Like Query
How to Select First 10 Words of a Sentence
Fatal Error: Cannot Use Object of Type MySQLi_Result
MySQLi_Fetch_Array While Loop Columns
How to Setup Elasticsearch Index Structure With Multiple Entity Bindings
How to Detect a Create, Update, Delete Query Is Successful in Codeigniter
Laravel Migration: Unique Key Is Too Long, Even If Specified
How to Import a .SQL File in MySQL Database Using PHP
How to Override the Path of PHP to Use the Mamp Path
How to Get Last Key in an Array
PHP: If Internet Explorer 6, 7, 8 , or 9