It is necessary to display pictures from folders in a loop, until it goes through everything. I tried to use the file_exists function , which checks the existence of the specified file or directory and thus, will perform a loop until the files in the specified directory end, but for some reason the construction does not work . The code is:
<?php echo "<div class='hidden-container'>";?> <?php $img = 1; $imgf = "/files/id$id/" .$img. ".jpg"; while (file_exists($imgf)) { echo "<a id='thumb1' class='highslide' href='/files/id$id/$img.jpg' onclick='return hs.expand(this, inPageOptions)'> <img src='../files/id$id/" .$img. "_thumb.jpg' alt='" . $myrow["title"] . "'/></a>"; $img = $img +1; } echo "</div> <div id='gallery-area' style='width: 620px; height: 520px; margin: 0 auto; border: 1px solid silver'></div>"; ?>
Attention, the correct answer:
<?php echo "<div class='hidden-container'>";?> <?php $img = 1; $imgf = "/files/id$id/" .$img. ".jpg"; while (file_exists($imgf)){ echo "<a id='thumb1' class='highslide' href='/files/id$id/$img.jpg' onclick='return hs.expand(this, inPageOptions)'> <img src='../files/id$id/" .$img. "_thumb.jpg' alt='" . $myrow["title"] . "'/></a>"; $img++; $imgf = "/files/id$id/" .$img. ".jpg"; } echo "</div> <div id='gallery-area' style='width: 620px; height: 520px; margin: 0 auto; border: 1px solid silver'></div>"; ?>
Answer the author of the question:
It was necessary to realize the output of pictures from a specific folder, but before that determine how many of them are there. The output was found, maybe a little curve, but it works fine! <? php $ path = "files / id1 / * _ big.jpg"; $ m = glob ($ path); $ col = count ($ m); $ col = $ col +1; ?>
while ($ img <$ col) {
} echo "
";?>
1.jpg
. Well, or2.jpg
(then it will work once). But that, in your understanding, "does not work," science is unknown. - Ali