Model:
public function exibir_noticia()
{
$consulta = $this->db->query('SELECT * FROM Noticia_Site_Cairu');
return $consulta->result();
}
Controller
public function index()
{
$this->load->model('noticia_model');
$consulta = $this->noticia_model->exibir_noticia();
//print_r($casdatrado);
$this->load->view('v_home', $consulta);
}
When I show in the view:
foreach ($consulta as $exibir):{
echo '
<tr class="success">
<td>'.$exibir->titulo.'</td>
<td>'.$exibir->texto.'</td>
<td>'.$exibir->imagem.'</td>
<td>'.$exibir->link.'</td>
<td>'.$exibir->nome_link.'</td>
<td>'.$exibir->video.'</td>
<td>'.$exibir->data.'</td>
</tr>';
}endforeach;
This error appears:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: query
Filename: views / v_home.php
Line Number: 88
Backtrace:
File: /var/www/html/admnoticias/application/views/v_home.php Line: 88 Function: _error_handler
File: /var/www/html/admnoticias/application/controllers/Home.php Line: 17 Function: view
File: /var/www/html/admnoticias/index.php Line: 315 Function: require_once