Here is my model - I want to assign the rows and echo out on the view page e.g <?php echo $product?>
class Model_products extends CI_Model {
function printer()
{
$id = $this->uri->segment(3, 0);
$q = $this->db->get_where('printer', array('id' => $id));
if ($q->num_rows == 1)
{
foreach ($q->result() as $row)
{
echo $row->name; # THIS WORKS
$data['product'] = $row->name; # THIS DOES NOT WORK
$data['desc'] = $row->description;
$data['size'] = $row->size;
$data['options'] = $row->options;
$data['more'] = $row->more_info;
}
}
}
}
Here's my controller
public function products()
{
$this->load->model('Model_products');
$this->Model_products->printer();
$this->load->view('products', $data);
$this->load->view('pricing');
}
My view is
<h1>
<?php echo $product; ?>
</h1>
<p>
<?php echo $desc; ?>
</p>
<h3>
Size
</h3>
<p>
<?php echo $size; ?>
</p>
How do I properly pass my model array to my controller so that I can echo out on my view?
$data = $this->Model_products->printer();