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.... 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? 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 :-) 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> 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] 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 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 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... 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 :-) 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 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
Archived
This topic is now archived and is closed to further replies.