开发者

PHP Extract multiple images from MySQL database field

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 th开发者_开发百科em on the front-end of the website in a thumbnail gallery? Any help greatly appreciated, S.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜