[eluser]souri84[/eluser]
hi everybody,
Sorry for my noob question and my bad english (I'm french - nobody is perfect... ;-D ) I just began with MVC and more precisly with codeIgniter.
To start, it's my code :
Controller :
Code:
<?php
class Visualisation extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->model('sidebar');
$data['title'] = 'titre';
$data['heading'] = 'titre2';
$data['menu']= $this->sidebar->get_all_entries();
$this->load->view('recherche',$data);
}
}
?>
Model:
I'm using PDO :
Code:
<?php
class Sidebar extends CI_Model
{
function __construct()
{
parent::__construct();
}
public function get_all_entries()
{
$query = $this->db->prepare('SELECT CH_TITRE FROM f_sidebar');
$data = $query->execute();
$data = $query->fetchAll();
return $data;
}
}
?>
View:
Code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="<?php echo base_url(); ?>css/style.css" />
<title><?php if(isset($title)) echo $title; ?></title>
</head>
<body>
<header>
<h3><?php if(isset($title)) echo $title; ?></h3>
</header>
<div id="sidebar">
<?php if(isset($menu)) echo $menu; ?>
</div>
<div id="content">
<?php
if(isset($heading)) echo $heading;
?>
</div>
</body>
</html>
My problem is my query returns an array so in my view, it indicates "Array" and that's all...
So my question is how to view datas listed in my database and not "Array" ?
Thanks,
Thibaut