Best practices:building html with CI - 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: Best practices:building html with CI (/showthread.php?tid=53245) |
Best practices:building html with CI - El Forum - 07-16-2012 [eluser]bill19[/eluser] Hello everyone, I am trying to build a dynamic portfolio page with a portion of the page made up a small html template fragment/"subview", each of which I would like to populate from a database. Therefore each subview corresponds to 1 database row . What is the best practice way in CI of looping through, populating and appending these subviews to an html page in codeigniter . An example of a 'subview' is: Code: <h2>$db field 1</h2> Best practices:building html with CI - El Forum - 07-16-2012 [eluser]Aken[/eluser] Load the items from your DB into the view, and then loop them. Code: <?php foreach ($results as $row): ?> Best practices:building html with CI - El Forum - 07-17-2012 [eluser]bill19[/eluser] Thanks Aken , for showing me the code. Only 1 slight syntax error keeps popping up though. When I use: Code: <?php foreach ($results as $row): ?> //// LINE 68 I get the following error: Quote:Parse error: syntax error, unexpected '<' ... AT LINE 68 I've been searching google, but its not obvious whats wrong here. Thank you, Bill Best practices:building html with CI - El Forum - 07-17-2012 [eluser]PhilTem[/eluser] Which PHP version are you using? I think older versions (below 5.0) don't support this kind of coding. Otherwise you just need to alter your code to include HTML-tags in your PHP code and not like you do right now include PHP within HTML tags Best practices:building html with CI - El Forum - 07-17-2012 [eluser]CroNiX[/eluser] PHP Docs say the alternative control structure syntax should work in PHP 4/5 Best practices:building html with CI - El Forum - 07-17-2012 [eluser]bill19[/eluser] I'm using php 5.35 Best practices:building html with CI - El Forum - 07-17-2012 [eluser]Aken[/eluser] You probably have an opening <?php tag already. Best practices:building html with CI - El Forum - 07-17-2012 [eluser]cideveloper[/eluser] Check above line 68. did you close the php above? Code: <?php Best practices:building html with CI - El Forum - 07-18-2012 [eluser]bill19[/eluser] That's it! Thank you guys, Bill |