2011-05-09 41 views
0

我从csv文件中提取数据并将其插入到MySQL数据库中。图像被插入到名为picturerefs的字段中,如下所示,并存储在单独的网站上。PHP从MySQL数据库字段中提取多个图像

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 

我该如何去提取这些图像,以便在缩略图库中的网站前端显示它们?任何帮助不胜感激,S.

+0

如果你可以插入它们,你应该能够检索它们。创建一个画廊完全是一个不同的问题。 – 2011-05-09 12:11:06

+1

是的,你有什么困难的部分?查询数据,分离文件名或建立图库? – 2011-05-09 12:11:57

+0

你可以发布你正在使用的数据库表吗? – 2011-05-09 12:12:13

回答

1

你应该这样做。

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

..等等

如果有7个文件名该列,那么你将有一个从0 $ file_names阵列至6

假设你正在使用里面的$行在从数据库获取数据后循环。