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? Quote 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>"; ?> Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.