Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to display all images in a folder?

Posted on 2008-10-10
4
Medium Priority
?
816 Views
Last Modified: 2010-04-21
Hello,

I'm using the attached code snippet to display all the images in a folder.

The problem is with this line:
<img src='../thumbphp/phpThumb.php?src=/travel_pics/$file/'.*.*.'&w=100' alt=''/>

I can't get the *.* to work - what am i doing wrong?


Cheers
<?php
if ($handle = opendir('travel_pics/'.$id.'/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "
<a id='thumb1' href='../public_html/travel_pics/$file/' onclick='return hs.expand(this)' class='highslide'>
<img src='../thumbphp/phpThumb.php?src=/travel_pics/$file/'.*.*.'&w=100' alt=''/>
</a>
";
}
}
closedir($handle);
}
?>

Open in new window

0
Comment
Question by:Daniish
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:babuno5
ID: 22685735
i dont know why you require *.*

just if it was supposed to be there then it should be

<img src='../thumbphp/phpThumb.php?src=/travel_pics/$file/.*.*.&w=100' alt=''/>
0
 
LVL 15

Accepted Solution

by:
babuno5 earned 1500 total points
ID: 22685790
i think this should work

echo "
<a id='thumb1' href='/travel_pics/$id/$file/' onclick='return hs.expand(this)' class='highslide'>
<img src='../thumbphp/phpThumb.php?src=/travel_pics/$id/$file/&w=100' alt=''/>
</a>
";
0
 

Author Comment

by:Daniish
ID: 22685905
I'm trying to get it to load all images from each folder....but as you can see it hasn't worked:

www.globxposure.net/index.php

Ultimately the purpose of this exercise is that when you click on an image (click on the Norwich marker), you get the option to view Next/Previous image - and i would like it to cycle through the images that are in the same folder as the image the user has just selected.

Hope you understand me.
0
 

Author Closing Comment

by:Daniish
ID: 31504956
This was a badly worded question on my part, however, another expert has helped me out so i no longer need to keep this open.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question