adammcmillan Posted September 11, 2008 Share Posted September 11, 2008 I have a normal mysql table full of information. I would like to display that information into multiple columns (3 columns). How can I achieve this using tables and PHP? Link to comment https://forums.phpfreaks.com/topic/123775-display-mysql-information-over-multiple-columns-in-a-table/ Share on other sites More sharing options...
sasa Posted September 11, 2008 Share Posted September 11, 2008 try <?php $result = mysql_query($sql) or die(mysql_error()); $ceil_in_row = 3; echo "<table>\n"; while ($row = mysql_fetch_array($result)){ echo "<tr>\n"; echo "\t<td>",$row['name'],"</td>\n"; for ($i = 1; $i < $ceil_in_row; $i++){ if ($row = mysql_fetch_array($result)) echo "\t<td>",$row['name'],"</td>\n"; else echo "\t<td> </td>\n"; } echo "</tr>\n"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/123775-display-mysql-information-over-multiple-columns-in-a-table/#findComment-639307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.