Hi again I have a list that is generated from my mysql db and i would like to output it into 3 equal columns on the page? is that possible? how would i approach it? Thanks Mike
Sure. Here is a quick approach: You have the data outputting loop, right? You will put: <table> before the loop and </table> after it. And add a counter to be used as a row reference. Now the loop will look like this: <table> <? $i = -1; while($rs=mysql_assoc($result)){ $i++; if($i/3 == intval($i/3)){ ?> <tr> <? } // Now echo the db row if(($i+1)/3 == intval(($i+1)/3)){ ?> </tr> <? } } ?> </table> PHP:
Perhaps I'm not seeing it correctly, but I believe their should be some <td></td> tags in there to allow the three columns Something to the effect of: <table> <tr> <td> (1/3 MySQL data) </td> <td> (1/3 MySQL data) </td> <td> (1/3 MySQL data) </td> </tr> </table> is this more what you were going for?
http://codewalkers.com/tutorials.php?show=15 This tutorial will show you how to do it. Its pretty easy to follow and works exactly for what you are trying to do.
Yes, <td> goes inside the loop, thanks for your note. <table> <? $i = -1; while($rs=mysql_assoc($result)){ $i++; if($i/3 == intval($i/3)){ ?> <tr> <? } ?> <td> <? // Now echo the db row ?> </td> <? if(($i+1)/3 == intval(($i+1)/3)){ ?> </tr> <? } } ?> </table> PHP: