Jump to content

$i++ photo url


LM

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.