freelancer Posted September 30, 2009 Share Posted September 30, 2009 Hello! I have form where I enter for example picture file names like this: test1.jpg, test2.jpg, test3.jpg etc. Now on page where I want these images to be displayed I need to explode them so let's say I have $picture[0], $picture[1], $picture[2] etc. My question and problems that how I can make them appear as seperate links depening on how many pictures were exploded to variables so i.e. when I have 2 images names in sql table then on my web it displays like www.test.com/test1.jpg, www.test.com/test2.jpg etc. Maybe explode isn't only solution and there could be any other ways to do it. Hope you understand my point and can help me! Link to comment https://forums.phpfreaks.com/topic/176103-solved-mysql-query-exploding-to-seperate-links/ Share on other sites More sharing options...
5kyy8lu3 Posted September 30, 2009 Share Posted September 30, 2009 explode will work. <?php $pics = explode(',', $_GET['pics']); $NumberOfPictures = count($pics); $location = 'http://www.YourWebSite.com/pictures/'; for ( $i = 0; $i < $NumberOfPictures; $i++ ) { echo $location . $pics[$i] . '<br>'; } ?> that would echo out a link for each picture, but i'm not completely sure that's what you were asking, it wasn't very clear. Link to comment https://forums.phpfreaks.com/topic/176103-solved-mysql-query-exploding-to-seperate-links/#findComment-927970 Share on other sites More sharing options...
freelancer Posted September 30, 2009 Author Share Posted September 30, 2009 Thanks that was exactly what I was looking for! Link to comment https://forums.phpfreaks.com/topic/176103-solved-mysql-query-exploding-to-seperate-links/#findComment-927982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.