toolman Posted December 17, 2009 Share Posted December 17, 2009 Hi there, How would I go about displaying content in two columns after I have selected the data from a database? At the moment I have all selected data in a single column, but wanted to display it in 2 columns automatically. This is my code: $result = mysql_query("select * from pmd_categories where level = '1' "); while($row = mysql_fetch_array($result)) { echo $row['title']; } I want the $row['title'] to be displayed in two columns. Any suggestions? Quote Link to comment Share on other sites More sharing options...
anthylon Posted December 18, 2009 Share Posted December 18, 2009 This seems the fastest way originally explained by TheBlueEys on another forum. It uses binary numbers but if you want to check read google it or do some testing. $result = mysql_query("select * from pmd_categories where level = '1' "); $counter = 0; while($row = mysql_fetch_array($result)) { if($counter & 1) { echo "Odd row here"; }else{ echo "Even row here"; } $counter++; } Of course you will have to make simple HTML in order to render your output in two columns. But I am assuming you are not requesting that kind of help . Quote Link to comment 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.