rkiss Posted March 28, 2006 Share Posted March 28, 2006 Hi,I am looking for a solution for the following issue:I am trying to split up my resultset into multiple colums, but I can't find anything that would fit my needs:Sample Output:A E IB F JC G KD H LDoes anyone have a solution or know some good tutorial?Thank YouRK Quote Link to comment https://forums.phpfreaks.com/topic/5976-3-or-more-multi-column-resultset/ Share on other sites More sharing options...
Barand Posted March 28, 2006 Share Posted March 28, 2006 This will giveABCDEFGHI[code]define ("NUMCOLS",3);$res = mysql_query("SELECT area, locname FROM baagriddata");$count = 0;echo "<TABLE border=1>";while (list($col1, $col2) = mysql_fetch_row($res)) { if ($count % NUMCOLS == 0) echo "<TR>\n"; # new row echo "<TD>$col1<br>$col2</TD>\n"; $count++; if ($count % NUMCOLS == 0) echo "</TR>\n"; # end row}if ($count % NUMCOLS != 0) { # end row if not already ended while ($count++ % NUMCOLS) echo "<td> </td>"; echo "</TR>\n";}echo "</TABLE>";[/code]To do it as you asked will reqire storing tha data into an array , calculating how many rows are needed, R, then outputting record n, n+R, n+2R into each row. Quote Link to comment https://forums.phpfreaks.com/topic/5976-3-or-more-multi-column-resultset/#findComment-21537 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.