foreach statement is giving syntax error |
<?php foreach ($records as $rows);?>
<?php echo $rows->firstname; ?> <?php endforeach; ?> When I put the above code in view i'm getting syntax error in the last line. But syntax looks to be fine. Anyone can help me why i'm getting Severity: Parsing Error Message: syntax error, unexpected 'endforeach' (T_ENDFOREACH) Filename: views/site_view.php
try this:
<?php foreach ($records as $rows):?> <?php echo $rows->firstname; ?> <?php endforeach; ?>
Be Simple
(08-01-2016, 09:58 PM)waptik Wrote: try this: waptik It did work well. I learnrd, that i did a syntax error by putting ; instead of : at the end of the foreach statement. Appreciate it and God Bless. PHP Code: <?php What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(08-01-2016, 08:55 PM)dilipan Wrote: <?php foreach ($records as $rows);?> You need the : at the end of the foreach () line you have the ; there. This creates the error as the endforeach does not have a opening line I personally dont use endif, endforech, etc. I prefer the use of { } that way the editor can easily spotting missing { } <?php foreach ($records as $rows) { echo $rows->firstname; } ?>
On the package it said needs Windows 7 or better. So I installed Linux.
(08-01-2016, 11:44 PM)dilipan Wrote:(08-01-2016, 09:58 PM)waptik Wrote: try this: You are welcome bro. But next time, kindly use this Code: foreach(condition){
Be Simple
|
Welcome Guest, Not a member yet? Register Sign In |