nathan1 Posted July 8, 2008 Share Posted July 8, 2008 Hey PHP Legends, I have a problem with echoing some stuff in php...(using smarty) - ive got some events im trying to echo out, trying to get a 3 x 3 events listing eg: EVENT ONE | EVENT TWO | EVENT THREE EVENT FOUR | EVENT FIVE | EVENT SIX EVENT SEVEN | EVENT EIGHT | EVENT NINE My Codes is; <table cellpadding='0' cellspacing='0' class='portal_table' align='left'> <tr><td bgcolor="#ff9933" height="40"><div style="padding-left: 5px; font-weight: bold;">EVENTS</div></td></tr> <tr> <td class='portal_box'> {section name=event_loop loop=$events max=3} {cycle name="startrow" values=" <table cellpadding='0' cellspacing='0' align='center'><tr bgcolor='99ccff'>,,,,"} <td class='portal_member'><div align="left"> <a href="event.php?event_id={$events[event_loop]->event_info.event_id}"> Title: {$events[event_loop]->event_info.event_title}<br />Description: {$events[event_loop]->event_info.event_desc}<br /> <img src='./images/nophoto.gif' width="177" height="135" border='0'> </a></div><br /><img src="images/table_final.gif" align="baseline"> </td> {* END ROW *} {if $smarty.section.event_loop.last == true} </tr></table> {else} {cycle name="endrow" values=",,,,</tr></table>"} {/if} {/section} I Know how to echo the events but don't know how to get the events to goto a next row after 3 events...i know its in smarty so if you could please tell me how to do it in php if you dont know smarty- would be appreciated. Thanks heaps Link to comment https://forums.phpfreaks.com/topic/113828-solved-php-echo-help/ Share on other sites More sharing options...
lemmin Posted July 8, 2008 Share Posted July 8, 2008 Set a variable for the columns: $column = 0; while (//echoing events) { if ($column == 2) { echo "<tr>"; $column = 0; } //echoing <td>'s } Link to comment https://forums.phpfreaks.com/topic/113828-solved-php-echo-help/#findComment-584924 Share on other sites More sharing options...
nathan1 Posted July 9, 2008 Author Share Posted July 9, 2008 I dont see how that would work, Im essentially echoing a loop out how do i say at the end of three insert a row? Link to comment https://forums.phpfreaks.com/topic/113828-solved-php-echo-help/#findComment-584955 Share on other sites More sharing options...
lemmin Posted July 9, 2008 Share Posted July 9, 2008 Use a variable to keep track of how many columns you have printed and print a new row every time it is three, like my code shows. Link to comment https://forums.phpfreaks.com/topic/113828-solved-php-echo-help/#findComment-585464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.