在phpexcel中插入空单元格的值

时间:2016-01-05 12:37:45

标签: php excel

在php中导入excel表时,我想要插入空单元格的值" N / A"对于数据库中的$ row8。我无法解决这个问题。任何人都可以帮我解决这个问题

for ($x = 2; $x <= count($data->sheets[0]["cells"]); $x++) 
                    {



                 $row1=$data->sheets[0]["cells"][$x][1];

                $row2=mysql_real_escape_string((string)$data->sheets[0]["cells"][$x][2]);
                $row3=mysql_real_escape_string($data->sheets[0]["cells"][$x][3]);
                $row4=mysql_real_escape_string($data->sheets[0]["cells"][$x][4]);
                $row5=mysql_real_escape_string($data->sheets[0]["cells"][$x][5]);
                $row6=mysql_real_escape_string($data->sheets[0]["cells"][$x][6]);
                $row7=mysql_real_escape_string($data->sheets[0]["cells"][$x][7]);
                $row8=mysql_real_escape_string($data->sheets[0]["cells"][$x][8]);
                $row9=mysql_real_escape_string($data->sheets[0]["cells"][$x][9]);
                $row10=mysql_real_escape_string($data->sheets[0]["cells"][$x][10]);
                $row11=mysql_real_escape_string($data->sheets[0]["cells"][$x][11]);
                $row12=mysql_real_escape_string($data->sheets[0]["cells"][$x][12]);
                $row13=mysql_real_escape_string($data->sheets[0]["cells"][$x][13]);
                $row14=mysql_real_escape_string($data->sheets[0]["cells"][$x][14]);
                $row15=mysql_real_escape_string($data->sheets[0]["cells"][$x][15]);
                $row16=mysql_real_escape_string($data->sheets[0]["cells"][$x][16]);
                $row17=mysql_real_escape_string($data->sheets[0]["cells"][$x][17]);
                $imagelink="images/vendor/".$timestamp."/".$row1.".jpg";
                $todaysdate=$prepdata;


                $groupname='Vendor';
                $groupid=2;
                $do=1;

                // Vendor Password
                $salt = time();
                $vend_name = $row3;
                //$vend_password = substr(sha1($vend_name . $salt),0,8);    
                $row5=trim($row5);
                $password=$row5;
                $password=md5($password);



            $lat=0;
            $lng=0;
                $row5=urlencode($row5);
                $geocode=file_get_contents("http://maps.google.com/maps/api/geocode/json?address=".$row5."&sensor=false");

                $output= json_decode($geocode);
                if($output->status!='ZERO_RESULTS')
                {
                $lat = $output->results[0]->geometry->location->lat;
                $lng = $output->results[0]->geometry->location->lng;
                }


                $insert_into_user_query = mysql_query($insert_into_user);


                 $insert_id=mysql_insert_id();

                 $insert_into_table="insert into `tablename` (`fk_id`, `address`, `latitude`, `longitude`, `phone`,`category`,`type`, `open_timing`, `closed_timing`, `logo`, `terms_condition`, `notes`, `tax_type`, `tax_value`, `website`, `date`) values ($insert_id,'$row6','$lat','$lng','$row9','$row7','$row8','$row11','$row12','$imagelink','$row14','$row13','$row16','$row17','$row15','$todaysdate')";
                $insert_into_table_res=mysql_query($insert_into_table);

我无法解决这个问题。任何人都可以帮我解决这个问题

0 个答案:

没有答案