Im doing a catalog like site that list a bunch of product images, and i want to line them up 3 a row, but im not sure how to code it. I was going to make a div for both float left, and right but i don't think it will work.what do you think?
use tables divide your recordset (you got after database selection) into 3 arrays, and then will generate html table use data from first, second, third the simpler way is <table> <? for ($i=0; $i<$cnt; $i++) { ?> <tr> <td><?=$arr1[$i] ?></td> <td><?=$arr2[$i] ?></td> <td><?=$arr3[$i] ?></td> </tr> <? } ?> </table> Code (markup):
hmmm sounds like it would work(even though i was told to saty away from tables) i dont get the $arr1[$i] ?> or any of that other strange stuff if you could clear that up i would much appreciate it
$arrX - it's arrays of prepared list for each columt $colnum=3; $arr=array(); for($i=0; $i<$colnum; $arr[$i++]=array()); $recordset=array(1,2,3,4,5,6,7,8); $cnt=count($recordset); $limit=1; $j=0; for($i=0;$i<cnt;$i++) { if ($i>$limit*$cnt/$colcnt) { $limit++; $j++; } $arr[$limit-1][$j++]=$recordset[$i]; } Code (markup): after performing you will get $arr[0]=(1,2,3), $arr[1]=(4,5,6) $arr[2]=(7,8) Sorry, if some mistakes - didn't checked the code but think, the idea is clear