PHP div columns
Display records 5 columns wide using Div’s.

<?PHP include('connection.php');//Connection to database $columns="5";//How many columns to display $r=0;//Set r to 0 $get_draft=mysql_query("SELECT * FROM your_table") or die(mysql_error()); while($rows=mysql_fetch_array($get_draft)){ $your_table=$rows['your_table']; $r++;//Add 1 to r $row .='<div class="row">'.$your_table.'</div>'; //Clear div every $columns if($r==$columns){ $row .='<div class="clear"></div>';//Or you can use <br /> $r=0;//Set r to 0 } } ?> <html> <head> <title>5 column wide records</title> <style type="text/css"> body{ margin:400px; font-family:arial; } .row{ border:solid #606060 1px; padding:5px; margin:10px; width:50px; float:left; } .clear{ clear:both; } </style> </head> <body> <h1>PHP 5 column wide records</h1> <?PHP echo $row; ?> </body> </html>
