Good morning Andy,
I love it when you don't use tables in your code. Let take 4images to another level
A small correction:
1- use $count or $i in your code instead of both.
2- Change:
$count = 0;to
$count = 1;Otherwise your list will start with the number 0.
So your code will look like this:
//$rows=40; //Wrap after how many lines
$rows= ($total_images/2) ;
$count = 1;
$sx = 0;
$video_list = "<div style=\"float:left;\">";
while ($image_row = $site_db->fetch_array($result)){
$video_list .= ($sx%$rows == 0) ? "</div>":"";
$video_list .= ($sx%$rows == 0) ? "<div style=\"float:left\">":"";
$video_list .= "<span style=\"margin-right:20px\" >".$count +."- <a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$image_row['image_id'])."\">".$image_row['image_name']."</a></span><br>";
$sx++;
}
$video_list .= "</div style=\"clear:both\">\n";
$site_template->register_vars("video_list", $video_list);
unset($video_list);This code is working perfect and solve the earlier problem (I will use it for another project
), but now you can get more that 2 columns. Because if you have 90 images, you will get 3 columns:40, 40 and 10.
Let say for our template we want only 2 columns.
How can we do that?