mysql - PHP pull specific sets of images from a directory -
i'm pulling image directory (images) , placing in html table row along mysql query. php finds image mysql db id matches image name. i.e. if id = 12 12.jpg pulled directory using $imgnum in path.
<?php if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $imgnum = $row["id"]; ?> <tr> <td> <img src="images/<?php echo $imgnum ?>.jpg"/>
the issue there may series of images associated row, i.e. 1-1.jpg 1-2.jpg , on, there may 1 , code above works fine.
is there way output images name equalling id dash afterwards picks other associated images? if can tell me learn achieve this?
cheers
you can use php's glob() find similar files. along lines of this:
foreach (glob("/path/to/images/folder/" . $imgnum . '-*') $filename) { // $filename }
Comments
Post a Comment