2 replies [Last post]
sionvalais
Offline
Regular
Last seen: 16 years 23 weeks ago
Joined: 2003-06-06
Posts: 49
Points: 0

I want to define a template where div's define rows with 3 images. the number of rows therefore depends on the number of images.
something like this
-------
img1 img2 img3
-------
img4 img5 img6
-------
img7 img8 imgx
-------
Has anyone an idea?

cheers,

Mark

milkman
Offline
newbie
Leicestershire, UK
Last seen: 16 years 2 weeks ago
Leicestershire, UK
Joined: 2003-11-04
Posts: 4
Points: 0

template php-css

Hey is this of any use to ya..? (It's missing most of the surrounding HTML/XHTML mark-up but..

<?php

$num_images = 9;

$n = 0;
while ($n < $num_images)
{
  echo "<div>\n";
  for ($i = 0; ( $i < 3 ) && ( $n < $num_images ); $i++ )
  {
    $n++;
    echo " <img src=\"image_$n.gif\" alt=\"image\" />\n";
  }
  echo "</div>\n";
}

?>

That will give something like..

<div>
 <img src="image_1.gif" alt="image 1" />
 <img src="image_2.gif" alt="image 2" />
 <img src="image_3.gif" alt="image 3" />
</div>
<div>
 <img src="image_4.gif" alt="image 4" />
 <img src="image_5.gif" alt="image 5" />
 <img src="image_6.gif" alt="image 6" />
</div>
<div>
 <img src="image_7.gif" alt="image 7" />
 <img src="image_8.gif" alt="image 8" />
 <img src="image_9.gif" alt="image 9" />
</div>

Sven
Sven's picture
Offline
Enthusiast
Brisbane, Australia
Last seen: 12 years 23 weeks ago
Brisbane, Australia
Timezone: GMT+10
Joined: 2003-03-12
Posts: 166
Points: 0

template php-css

You could always just apply an appropriate margin to the images, and let them just run across the page as per usual. If you need to restrict the number of images that fit across before wrapping, you could enclose the images in a fixed-size div...

Did that make sense? :roll: