Jump to content

echoing an image with a <a href link and some styling issues


Recommended Posts

Hi there!

 

Hope everyone is well.  I am in need of some further help if you do not mind.

 

I am using this code:

 

<?php
        $handle = opendir ('./thumbnails/');
        while (false !== ($file = readdir($handle))) {
            if($file != "." && $file != ".." && $file != basename(__FILE__)) {
			echo '<img src="./thumbnails/'.$file.'">';

            }
        }
?>

 

to output the images of the thumbnails directory...  I am struggling to include the link for each thumbnail as:

 

"./uploadedimages/'.$file.'"

 

I am getting very confused amongst all the single and double quotation marks!  That is my first question if anyone would be kind enough to help me?  Secondly I would like to style the images with CSS, how is this possible?  Do I just wrap a div id around the echo statement?

 

Thankyou very much in advance :)

 

Best wishes, Luke

Link to comment
https://forums.phpfreaks.com/topic/102355-echoing-an-image-with-a/
Share on other sites

<?php
        $handle = opendir ('./thumbnails/');
        while (false !== ($file = readdir($handle))) {
            if($file != "." && $file != ".." && $file != basename(__FILE__)) {
			print "<img src='./thumbnails/{$file}'>";

            }
        }
?>

Thankyou!  The line now reads:

 

print "<a href='./uploadedimages/{$file}'> <img src='./thumbnails/{$file}'></a>";

 

...and it works perfectly.  Now how do I go about laying out the images appropriately?  Can I place them either within a simple table or style them with CSS?  Many thanks :)

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.