header white Data - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1) +--- Forum: Regional User Groups (https://forum.codeigniter.com/forumdisplay.php?fid=25) +--- Thread: header white Data (/showthread.php?tid=69147) |
header white Data - Germanikus - 10-13-2017 Hello everybody, I wanted to include a loop in my template header.php. Unfortunately I get with the foreach an error message. What have I done wrong? Controller: PHP Code: <?php Model: PHP Code: <?php header.php Code: <?php foreach ($header_warenkorbs as $warenkorb): ?> RE: header white Data - InsiteFX - 10-13-2017 What error are you getting you did not show one? RE: header white Data - Germanikus - 10-13-2017 Sory forgettet Quote:A PHP Error was encountered RE: header white Data - PaulD - 10-14-2017 You should always check a foreach variable is not empty before doing the foreach loop. The error is telling you your variable is not set. If it is not set, but you are trying to set it with your model call, then your model must not be returning the values you expected. Looking at your models called function, which looks fine, are you sure you have any data in the table you refer to? PS You could write it like this btw: PHP Code: public function header_warenkorbs() And since select * is the default, and get accepts a table name, you could do: PHP Code: public function header_warenkorbs() Paul |