LM Posted October 11, 2011 Share Posted October 11, 2011 I'm having a problem understanding how to import more than one photo in a list of up to 20 photos. I can only import 1 photo from a comma delimited csv with a pipe between each photo url. <? function getImg($value,$userid, $stocknum){ $photoStr = ''; if($value !=''){ $photoURLs = explode('|', $value); for($i=0; $i<count($photoURLs);$i++){ $url = $photoURLs[$i]; $j = $i+1; if (@copy($url, "../upload/".$userid."/".$userid."_".$stocknum."_".$j.".jpg")) { $photoStr .= $userid."_".$stocknum."_".$j.".jpg|"; } } } return $photoStr; } ?> And after csv and sql <? if($img){ $img = rtrim($img, '|'); $imgArray = explode('|', $img); $imgIndex = 1; foreach ($imgArray AS $imgItem){ $db->query("UPDATE `stockitem` SET img".$imgIndex."= '$imgItem' where stocknum='$stocknum'","" , __FILE__, __LINE__); $imgIndex++; } } ?> Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/248915-i-photo-url/ Share on other sites More sharing options...
freelance84 Posted October 11, 2011 Share Posted October 11, 2011 So what is or isn't happening? Link to comment https://forums.phpfreaks.com/topic/248915-i-photo-url/#findComment-1278402 Share on other sites More sharing options...
LM Posted October 12, 2011 Author Share Posted October 12, 2011 Hi, I am able to get one photo per "stocknum" imported but want to import all photos listed per "stocknum" in the csv file. Link to comment https://forums.phpfreaks.com/topic/248915-i-photo-url/#findComment-1278561 Share on other sites More sharing options...
freelance84 Posted October 12, 2011 Share Posted October 12, 2011 I'm having a problem understanding how to import more than one photo in a list of up to 20 photos. I can only import 1 photo from a comma delimited csv with a pipe between each photo url. <? function getImg($value,$userid, $stocknum){ $photoStr = ''; if($value !=''){ $photoURLs = explode('|', $value); for($i=0; $i<count($photoURLs);$i++){ $url = $photoURLs[$i]; $j = $i+1; if (@copy($url, "../upload/".$userid."/".$userid."_".$stocknum."_".$j.".jpg")) { $photoStr .= $userid."_".$stocknum."_".$j.".jpg|"; } } } return $photoStr; } ?> And after csv and sql <? if($img){ $img = rtrim($img, '|'); $imgArray = explode('|', $img); $imgIndex = 1; foreach ($imgArray AS $imgItem){ $db->query("UPDATE `stockitem` SET img".$imgIndex."= '$imgItem' where stocknum='$stocknum'","" , __FILE__, __LINE__); $imgIndex++; } } ?> Any help would be appreciated. So after running this, if you echo $photoStr what do you get? Also, where does $img get created? Link to comment https://forums.phpfreaks.com/topic/248915-i-photo-url/#findComment-1278619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.