Welcome Guest, Not a member yet? Register   Sign In
Pass data to a partial inside a loop
#1

Hi

This is the first time I'm using CI and I have a questiona about getting data inside a partial within a loop.

On the controller I call the view with an array of data:

PHP Code:
return view('numero'$data); 

In the main view I have:

PHP Code:
<?php foreach ($items as $item) : ?>

<?= $item['id']; ?>

<?= $this->include('partials/item'?>

<?php endif ?>

In the partial I have:
PHP Code:
<?= $item['name']; ?>

and I get an error saying "Undefined variable: item"

How am I able to make this work?
Thanks
Reply


Messages In This Thread
Pass data to a partial inside a loop - by nneves - 06-21-2020, 04:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB