loudrake Posted March 7, 2007 Share Posted March 7, 2007 The code below allows me to show the logos for all partners listed in our database. However, it shows the logos all on one long row when they appear on the page. I can add a <tr> within the loop but then just get one logo per row. How do I make it show only 3 logos in each row until it has shown all partner logos in the db? Thanks! <? ////////////////////////////////////// //Show partners echo "<table align='left' width='100%'><span class='bodycopy12'>$table_message</span><br><br>"; echo "<tr><td><table align='left' width='100%' border='1' bordercolor='cccccc' cellspacing='0' cellpadding='5'>"; echo "<tr>"; for($i = 0; $i < count($partner_array) ; $i++) { echo "<td align='center' width='315'>"; echo "<img src=../uploads/" . $partner_array[$i]["LOGO"] . ">"; echo "</td>"; } echo "</table>"; echo "</td>"; echo "</tr>"; echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/41587-solved-need-to-add-to-array-listing/ Share on other sites More sharing options...
monk.e.boy Posted March 7, 2007 Share Posted March 7, 2007 <?php echo "<table align='left' width='100%' border='1' bordercolor='cccccc' cellspacing='0' cellpadding='5'>"; echo "<tr>"; $count = 0; for($i = 0; $i < count($partner_array) ; $i++) { echo "<td align='center' width='315'>"; echo "<img src=../uploads/" . $partner_array[$i]["LOGO"] . ">"; echo "</td>"; $count++; if( $count==3 ) { // we have shown 3 logos, now insert and new row: echo '</tr><tr>'; $count = 0; } } // BUG:?? // echo "</table>"; // echo "</td>"; echo "</tr>"; echo "</table>"; ?> Also look up the mod (%) command, this is a little harder to understand, but it would work really well in this situation. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/41587-solved-need-to-add-to-array-listing/#findComment-201558 Share on other sites More sharing options...
loudrake Posted March 7, 2007 Author Share Posted March 7, 2007 Thanks for the help monk.e.boy, I appreciate it! Link to comment https://forums.phpfreaks.com/topic/41587-solved-need-to-add-to-array-listing/#findComment-201579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.