阅读背景:

ForEach循环数据插入两个数据库表

来源:互联网 
$imagesarray[]=explode('&',$data[5]);
            $imag_temp  =   0;
            foreach($imagesarray as $image){
                if($imag_temp == 0 )
                {
                    $this->db->query("UPDATE " . DB_PREFIX . "product SET image = 'media/" . $image[0] . "' WHERE product_id = '" . (int)$product_id . "'");
                }else{
                    foreach($image as $img){
                            $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET image = 'media/" . $img . "' , product_id = '" . (int)$product_id . "'");
                    }
                }
                $imag_temp++;               

            }

This is my $data[5]=Arizona Diamondbacks.png&arizona-cardinals.png&Atlanta Braves.jpg&...&...&...n number can have..
$imagesarray[]=explode('&',$data[5]);
         



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: