SOLVED: Add <div> around every 10 queried results? - 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: Add <div> around every 10 queried results? (/showthread.php?tid=9402) |
SOLVED: Add <div> around every 10 queried results? - El Forum - 06-24-2008 [eluser]Joakim_[/eluser] Hi. I wondering if it's possible to add a <div> around every 10 queried results, without using multiple queries. Let's say there are 22 results from the query and I want something like this: Code: <div class="item_holder"> Thank you very much for your help! SOLVED: Add <div> around every 10 queried results? - El Forum - 06-24-2008 [eluser]Dagobert Renouf[/eluser] I would add a $i variable that you would increment at each returning row. Then you check : Code: if(is_int($i / 10) == TRUE) However there's probably a better way to do this. SOLVED: Add <div> around every 10 queried results? - El Forum - 06-24-2008 [eluser]Joakim_[/eluser] [quote author="Dagobert Renouf" date="1214331108"]I would add a $i variable that you would increment at each returning row. Then you check : Code: if(is_int($i / 10) == TRUE) However there's probably a better way to do this.[/quote] Thank you a lot for your reply and help. I'm not sure where to add the $i variable? I have the PHP code like this: Code: <?php foreach($query->result() as $row): ?> Thank you! SOLVED: Add <div> around every 10 queried results? - El Forum - 06-24-2008 [eluser]xwero[/eluser] You can use the key of the array Code: <?php foreach($query->result() as $i=>$row): ?> But i wouldn't recommend to put divs in a list. If you want to put a wrapper around every 10 items you better do Code: <ul> SOLVED: Add <div> around every 10 queried results? - El Forum - 06-24-2008 [eluser]Joakim_[/eluser] It works! Thank you a lot. |