Jump to content

Problem appending data to a $ in a while loop


ActaNonVerba1

Recommended Posts

Hey guys

 

This is the first loop i have attempted on my own, so please tell me if ive done something completely stupid..

 

What happens is the suer specifies a number of thumbnails on the previous page, these are posted to the form and then that amount of thumbnails should be displayed.

 

Heres what i have so far

	$cd = 0;
	while ($cd < $numberofthumbnails) {
	$displaythumbs . '<div class="ThumbnailHolder">
    	<div class="LeftThumb"><a class="group" href="../../../Images/Lighthouses/Beachy-Head/1.png"><img src="../../../Images/Lighthouses/Beachy-Head/Mini/Thumbnail-1.png" width="430" height="200" alt="Thumbnail 1"></a></div>
    	<div class="RightThumb"><a class="group" href="../../../Images/Lighthouses/Beachy-Head/2.png"><img src="../../../Images/Lighthouses/Beachy-Head/Mini/Thumbnail-2.png" width="430" height="200" alt="Thumbnail 2"></a></div></div>
';
	$cd++;
}	

 

Essentially what im trying to do is as thumbnail code to $displaythumbs for each time the loop goes round. What am i doing wrong?

 

Thanks

 

Danny.

 

I'm not sure what's going on with "LeftThumb" and "RightThumb". But if you're trying to display one thumbnail per loop, you want to utilize the $cd variable in the loop. For example:

 

for($cd=0; $cd < $numberofthumbnails; $cd++) {
$displaythumbs . '<div class="ThumbnailHolder">';
$displaythumbs . '<div><a class="group" href="../../../Images/Lighthouses/Beachy-Head/' . $cd . '.png"><img src="../../../Images/Lighthouses/Beachy-Head/Mini/Thumbnail-' . $cd . '.png" width="430" height="200" alt="Thumbnail ' . $cd . '"></a></div>';
$displaythumbs . '</div>';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.