andz Posted May 11, 2008 Share Posted May 11, 2008 i already asked this question yesterday on how to view records in 3 column format. i only asked that time a simple view of records. here's the code yesterday that will allow me to view records in simple view (3 column format) <?php $show = range(1,15); foreach ($show as $i => $data) { echo $data; if (($i + 1) % 3 == 0) { echo ' \n'; } else { echo ' | '; } } ?> i need a code to view this kind of result in a table format. 3 column format also. just replace the '\n' with break line "br" Link to comment https://forums.phpfreaks.com/topic/105102-solved-view-records-in-3-column-format/ Share on other sites More sharing options...
mlin Posted May 11, 2008 Share Posted May 11, 2008 it's easier to use 2 variables in your loop. something like this: $show = range(1,15); $array_length = count($show); echo '<table>'; for ($i = 0, $k = 1; $i < $array_length; $i++, $k++) { if ($k == 1) echo '<tr>'; echo '<td>'.$show[$i].'</td>'; if ($k == 3 || ($i + 1) == $array_length) { echo '</tr>'; $k = 0; } } echo '</table>'; Link to comment https://forums.phpfreaks.com/topic/105102-solved-view-records-in-3-column-format/#findComment-538094 Share on other sites More sharing options...
andz Posted May 11, 2008 Author Share Posted May 11, 2008 thanks for the helped. i owe you one. Link to comment https://forums.phpfreaks.com/topic/105102-solved-view-records-in-3-column-format/#findComment-538104 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.