Hello
In controller
I have the following:
public function index() {
$data['demandas'] = $this->demandas_model->get_demandas();
$data['main_view'] = 'demandas/index';
$this->load->view('layouts/main', $data);
}
No model
in function get_demandas
I have the following:
public function get_demandas() {
$query = $this->db->get('demandas');
return $query->result();
}
And in view
it displays as follows:
<?php foreach($demandas as $demanda): ?>
<tr>
<?php echo "<td><a href='". base_url()."index.php/demandas/edit_view/". $demanda->da_id ."'>".$demanda->da_id."</a></td>" ?>
<?php echo "<td>".$demanda->us_id."</td>" ?>
<?php echo "<td>".$demanda->da_descricao."</td>" ?>
<?php echo "<td>".$demanda->da_data."</td>" ?>
// mais código
Where $demanda->us_id
is written, instead of displaying the code, I need to display the user name.
In the model, in the get_demandas
function, I get the id
and the nome
of the user to return through another call of another model and put in $data['demandas']
, but I do not know how to put it in the view, through of function index
of controller
.
This is the function
which returns me the user data, model
:
public function get_usuario($id) {
$this->db->where('us_id', $id);
$query = $this->db->get('usuarios');
return $query->result();
}
Thank you