[eluser]incog03[/eluser]
Hi Everyone
I'm trying to pull information from a single row in the database and display it in multiple views. In the model i have
Code:
$pagey = $pre->pageyinfo;
and CI is telling me I can't do this on a non-object - is there a way to fix this or anyway I can work around it? The code works fine except for the line above (and x5 times below).
Preview.php Model
Code:
function getPreview(){
$pre = $this->db->get('deals', 1);
if($pre->num_rows() > 0){
foreach($pre->result() as $row){
$data[] = $row;
}
}
foreach($row as $pre){
$pagex = $pre->pageXinfo;
$pagex2 = $pre->pagex2info;
$pagey = $pre->pageyinfo;
$pagey2 = $pre->pagey2info;
$pagez = $pre->pagezinfo;
$pagez2 = $pre->pagez2info;
}
$data['pagex'] = $pagex;
$data['pagex2'] = $pagex2;
$data['pagey'] = $pagey;
$data['pagey2'] = $pagey2;
$data['pagez'] = $pagez;
$data['pagez2'] = $pagez2;
return $data;
}
In the controller I have this;
preview.php
Code:
function index{
$data = $this->previewm->getPreview();
$this->load->view('header', $data);
$this->load->view('bodytop', $data);
$this->load->view('bodybottom', $data);
$this->load->view('footer', $data);
}
So I can dynamically update say the title in the view by;
header.php
Code:
<title><?php echo $pagex ?></title>
Any possible solutions would be fantastic, the reason I want to do this is because I found having a foreach loop stretching throughout all the views to be really messy I guess.
Maybe the pros do it like that but I don't know...