0

I'm pulling in data from a csv file and inserting it into a MySQL database. The images are being inserted into a field called picturerefs, example shown below, and are stored on a seperate website.

http://images.somesite.co.uk/foldername/image28177_1b.jpg,
http://images.somesite.co.uk/foldername/image28177_2b.jpg,
http://images.somesite.co.uk/foldername/image28177_3b.jpg,
http://images.somesite.co.uk/foldername/image28177_4b.jpg,
http://images.somesite.co.uk/foldername/image28177_5b.jpg,
http://images.somesite.co.uk/foldername/image28177_6b.jpg,
http://images.somesite.co.uk/foldername/image28177_7b.jpg,
http://images.somesite.co.uk/foldername/image28177_8b.jpg,
http://images.somesite.co.uk/foldername/image28177_9b.jpg

How would I go about extracting these images in order to display them on the front-end of the website in a thumbnail gallery? Any help greatly appreciated, S.

5
  • If you could insert them, you should be able to retrieve them as well. Creating a gallery is a different issue altogether. Commented May 9, 2011 at 12:11
  • 1
    Yeah, what part of the operation are you having difficulty with? Querying the data, separating the file names, or building the gallery? Commented May 9, 2011 at 12:11
  • can you post the database table you are using. Commented May 9, 2011 at 12:12
  • Having trouble seperating the filenames... Commented May 9, 2011 at 12:14
  • use php's pathinfo() for extracting filename. have a look at this function php.net/manual/en/function.pathinfo.php Commented May 9, 2011 at 12:18

1 Answer 1

1

You should do .

$file_names = explode("," , $row['picturerefs']);
echo $file_names[0];
echo $file_names[1];

.. so on

If there are 7 file names in that column, then you will have a $file_names array from 0 to 6.

Assuming you are using $row inside the loop after getting the data from the DB.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.