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.

 

Link to comment
Share on other sites

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>';
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.