this is my script but somthing is going wrong. It does not close who can help? <?php $aantalrijen=3; $teller=0; echo '<table><tr>'; foreach ( $dataitems as $item ) { $u=$item['url']; $i=$item['img']; $f=$item['feed']; print '<td> <a title="'.$f.'" rel="nofollow" target="_blank" href="'.$u.'"><img src="'.$i.'" alt=""/></a></td>'; } $teller++; if (! $teller % $aantalrijen) { echo "</tr>/n<tr>"; } } ?> </tr></table></div></div>
Your problem is that you have closed your foreach loop too soon: error: <?php $aantalrijen=3; $teller=0; echo '<table><tr>'; foreach ( $dataitems as $item ) { $u=$item['url']; $i=$item['img']; $f=$item['feed']; print '<td> <a title="'.$f.'" rel="nofollow" target="_blank" href="'.$u.'"><img src="'.$i.'" alt=""/></a></td>'; } // THE PROBLEM IS HERE $teller++; if (! $teller % $aantalrijen) { echo "</tr>/n<tr>"; } } ?> </tr></table></div></div> PHP: Correct: <?php $aantalrijen=3; $teller=0; echo '<table><tr>'; foreach ( $dataitems as $item ) { $u=$item['url']; $i=$item['img']; $f=$item['feed']; print '<td> <a title="'.$f.'" rel="nofollow" target="_blank" href="'.$u.'"><img src="'.$i.'" alt=""/></a></td>'; $teller++; if (! $teller % $aantalrijen) { echo "</tr>/n<tr>"; } } // Here is where the foreach loop should close ?> </tr></table></div></div> PHP:
Nope, now i get Parse error: syntax error, unexpected $end somthing is going wrong. Whiout the coloms and just getting the info everthing goes well but i want it in colloms. Greetings already thank 10 $ for the person who solves it
This is the original code so i want it in coloms and rows <?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); function DatamerchantMenu(&$dataitems,&$params) { ?> <div class="module"> <div class="mod_datamenu" style="text-align:center"> <?php foreach ( $dataitems as $item ) { $u=$item['url']; $i=$item['img']; $f=$item['feed']; print '<a title="'.$f.'" rel="nofollow" target="_blank" href="'.$u.'"><img src="'.$i.'" alt=""/></a><br/><br/>'; } echo "</div> </div>"; }
<?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); function DatamerchantMenu(&$dataitems,&$params) { ?> <div class="module"> <div class="mod_datamenu" style="text-align:center"> <table> <tr> <?php $cols = 3; $count = 0; foreach ( $dataitems as $item ) { $u=$item['url']; $i=$item['img']; $f=$item['feed']; print '<td><a title="'.$f.'" rel="nofollow" target="_blank" href="'.$u.'"><img src="'.$i.'" alt=""/></a></td>'; $count++; if($count == $cols){ print '</tr><tr>'; $count = 0; } } ?> </tr> </table> </div> </div> <?php } ?> PHP: checked this on my server (with the access restriction commented out) and there are no parsing errors (I would imagine the reason you got a parse error before was because I removed the final brace as I didn't know this was part of a function).