![]() |
[SOLVED]Endforeach error and data viewing not appearing - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [SOLVED]Endforeach error and data viewing not appearing (/showthread.php?tid=33628) |
[SOLVED]Endforeach error and data viewing not appearing - El Forum - 09-02-2010 [eluser]Redwhirl[/eluser] I have a problem with my controller, here is the code function index() { $this->load->model('welcome_model'); $data['rows'] = $this->welcome_model->getAll(); $this->load->view('welcome_message',$data); } Nothing appears in my view, but if I make a print_r($data), the data appears. Now in my view I have another problem, I have this code <?php foreach($rows as $r) : ?> <?php echo $r->prod_name; ?> <?php echo $r->nb_tickets_sold; ?> <? php endforeach; ?> and when I run it, I get this error : Parse error: syntax error, unexpected $end in C:\WampServer\www\CodeIgniter\Project_R\application\views\welcome_message.php on line 58 I have checked the syntax seems to be right. A helping hand would be appreciated Thanks [SOLVED]Endforeach error and data viewing not appearing - El Forum - 09-02-2010 [eluser]danmontgomery[/eluser] Code: <? php endforeach; ?> should be Code: <?php endforeach; ?> Although I don't really see the purpose of opening and closing php tags on 4 consecutive lines, or using endforeach at all: Code: <?php foreach($rows as $r) { [SOLVED]Endforeach error and data viewing not appearing - El Forum - 09-02-2010 [eluser]Redwhirl[/eluser] Thank you for this real fast help :d I use for lines, because I am following a video I have seen from Tuts.com, and I will have to add some bolding when echoing the data Thanks again Hubert [SOLVED]Endforeach error and data viewing not appearing - El Forum - 09-02-2010 [eluser]danmontgomery[/eluser] Code: echo '<strong>'.$r->prod_name.'</strong>'; [SOLVED]Endforeach error and data viewing not appearing - El Forum - 09-02-2010 [eluser]MartÃn[/eluser] Could you post your model? Maybe you have a problem there. Regards. [SOLVED]Endforeach error and data viewing not appearing - El Forum - 09-02-2010 [eluser]Redwhirl[/eluser] @noctrum Thanks a lot you solved everything in less then 2 minutes ![]() Great !!! SOLVED |