Xiode Posted January 17, 2007 Share Posted January 17, 2007 I was wondering if anyone had any examples on how I could get my output on different columns... Like Instead of it coming out one by one down the page... Place them in a 3 columns.... Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/ Share on other sites More sharing options...
dgiberson Posted January 17, 2007 Share Posted January 17, 2007 could you maybe explain this a bit more?do you mean like?| Col 1 | Col 2 | Col 3 || $var1 | $var2 | $var3 |or Row 1 | $var 1Row 2 | $var2Row 3 | $var3? Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163009 Share on other sites More sharing options...
taith Posted January 17, 2007 Share Posted January 17, 2007 assuming you have a database...[code]<?$result=mysql_query("SELECT * FROM table");$i=0;echo '<table>';while($row=mysql_fetch_array($result)){ if($i==0) echo '<tr>'; echo ' <td>'.$row[row1].'</td>'; echo ' <td>'.$row[row2].'</td>'; echo ' <td>'.$row[row3].'</td>'; $i++; if($i==3){ $i=0; echo '<tr>'; }}echo '</table>';?>[/code]something to that effect :-) Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163012 Share on other sites More sharing options...
Xiode Posted January 18, 2007 Author Share Posted January 18, 2007 Maybe I am not seeing this in the code.......... I am pulling some things from the DB.. each row will have it's own box.. I want 3 boxes to go across the page then start a new tr....Something like this<tr> <td> DB ROW 1 </td> <td> DB ROW 2 </td> <td> DB ROW 3 </td></tr><tr> <td> DB ROW 4 </td> <td> DB ROW 5 </td> <td> DB ROW 6 </td></tr> Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163830 Share on other sites More sharing options...
taith Posted January 18, 2007 Share Posted January 18, 2007 [code]<?$result=mysql_query("SELECT * FROM table");$i=0;echo '<table>';while($row=mysql_fetch_array($result)){ if($i==0) echo '<tr>'; echo ' <td>'.$row[columnname].'</td>'; $i++; if($i==3){ $i=0; echo '<tr>'; }}echo '</table>';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163833 Share on other sites More sharing options...
Xiode Posted January 18, 2007 Author Share Posted January 18, 2007 IS[code] if($i==3){ $i=0; echo '<tr>';[/code]Suppose to be[code] if($i==3){ $i=0; echo '</tr>';[/code]?:P Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163843 Share on other sites More sharing options...
taith Posted January 18, 2007 Share Posted January 18, 2007 right... that was my typo lol Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163844 Share on other sites More sharing options...
Xiode Posted January 18, 2007 Author Share Posted January 18, 2007 Thanx man... Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163861 Share on other sites More sharing options...
taith Posted January 18, 2007 Share Posted January 18, 2007 no problem... anytime :-) Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163868 Share on other sites More sharing options...
Xiode Posted January 18, 2007 Author Share Posted January 18, 2007 Trust me... I will have quite a bit more :S Quote Link to comment https://forums.phpfreaks.com/topic/34602-output-in-different-table-columns/#findComment-163880 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.