I have this function in my controller:
public function checkout(){
$data['items'] = $this->cart_model->get_items();
$this->load->view("templates/header");
$this->load->view("cart/checkout", $data['items']);
}
Inside the checkout view I try to use this variable:
<?php foreach($items as $k => $item){?>
But this results in an error:
Message: Undefined variable: items
Any suggestions on how to fix this?
$data['items'], just use$this->load->view("cart/checkout", $data);, then on your view file, use$items, or as you would do normally,foreach ($items as $item) { // code here }