PHP Question

I need an ordered 6 automated div css boxes which looks like Facebook photo album

I need a div css boxes every time with html-php content, when its in one row 6 pieces of boxes exist automated starts under and again 6 boxes and goes on what I exactly mean is a behaivour like in facebook album just the difference facebook has 4 Photos for every row i need six and not photos but a just div css boxes which will contain *.php files and will be produced through a form in same page, for example i give in form name John Doe in one box and Bill Clinton in second box and so on.

here is my try

<body>
<div class="header">
header
</div>
<?php
$dir= opendir(".") or die ('Cannot open directory');
$div="<div class=\"left1\">\n";
echo "<div class=\"wrapper\">\n";
for( $i=0; $i<6; $i++){
while(($file = readdir($dir)) != false){
if(preg_match("/php$/", $file)){
echo $div;
include($file);
echo "</div>\n";
}
}
}
echo "</div>\n";

?>
</body>
</html>


but it doesn't work as I wish.

Answer

Just do the following :

<?php 

for($j=1; $j < 13; $j++) : 

print '<div style="float:left;width:100px">';

    print 'your content here for the div. change width and loop numbers as needed';

print '</div>';

//magic is here
if($j%6==0) print '<div style="clear:both;"></div>';

endfor; 
Comments