<?php
set_time_limit(0);
$filepath=$_GET['uploadfile'];
require_once '../conn.php';
error_reporting(E_ALL ^ E_NOTICE);
$line=0;
$shipments=0;
$i=0;
$s=0;
$f=0;
$strSqla="SELECT MAX(number) FROM `sale_orders_restock`"; //查询sale_orders_restock表id字段最大值
$querya = mysql_query($strSqla,$conn);
$resultaa= mysql_fetch_row($querya);
$maxnum=$resultaa[0];
$maxnum++;
$file = fopen($filepath,"r") or die("打开文件失败");
while (!feof($file)) {
$buffer = fgets($file);
if ($line<>0)
{
$u=explode(' ', trim($buffer));
if(!empty($u[0])){
$sku=$u[10];
$sql_itemcode="SELECT * FROM `sku_rule` WHERE `sku` = '$sku'";
$querya = mysql_query($sql_itemcode,$conn);
$rs= mysql_fetch_array($querya);
$jj_sku=$rs['item_code'];
$delivery_areas=$rs['delivery_areas'];
$zhanghao=$rs['account'];
$or_id=$u[0];
$or_it_id=$u[1];
$payments_date=$u[3];
$buyer_email=$u[7];
$buyer_name=mb_convert_encoding(addslashes($u[8]), 'UTF-8','utf-8, shft-jis, gbk');
$buyer_phone=mb_convert_encoding(addslashes($u[9]), 'UTF-8','utf-8, shft-jis, gbk');
$product_name=mb_convert_encoding(addslashes($u[11]), 'UTF-8','utf-8, shft-jis, gbk');
$quantity=$u[12];
$recipient_name=mb_convert_encoding(addslashes($u[16]), 'UTF-8','utf-8, shft-jis, gbk');
$ship_address1=mb_convert_encoding(addslashes($u[17]), 'UTF-8','utf-8, shft-jis, gbk');
$ship_address2=mb_convert_encoding(addslashes($u[18]), 'UTF-8','utf-8, shft-jis, gbk');
$ship_address3=mb_convert_encoding(addslashes($u[19]), 'UTF-8','utf-8, shft-jis, gbk');
$ship_city=mb_convert_encoding(addslashes($u[20]), 'UTF-8','utf-8, shft-jis, gbk');
$ship_state=mb_convert_encoding(addslashes($u[21]), 'UTF-8','utf-8, shft-jis, gbk');
$ship_postal=mb_convert_encoding(addslashes($u[22]), 'UTF-8','utf-8, shft-jis, gbk');
$ship_country=mb_convert_encoding($u[23], 'UTF-8','utf-8, shft-jis, gbk');
$cancel_order=0;
$logistics_number="";
$logistics_company="";
$strSql_item="SELECT * FROM `jperp`.`1_item_codes` WHERE `item_code`='$jj_sku'";
$query_item = mysql_query($strSql_item,$conn);
$rs=mysql_affected_rows();
$kit=0;
if($rs>1)
{
while($rs = mysql_fetch_array($query_item) ){
$or_it="";
$jj_sku=$rs['stock_id'];
$item_quantity=$rs['quantity'];
$quantity=$quantity*$item_quantity;
if($kit>0){
$or_it=$or_it_id.$kit;
}
else
{
$or_it=$or_it_id;
}
$sql_sale=" INSERT INTO `amazon_erp`.`sale_orders_restock` (`number` ,`order_id` ,`order_item_id`,`shipments` ,`payments_date` ,`buyer_email` ,`buyer_name`,`buyer_phone_number`,`sku`,`jj_sku`,`product_name`,`quantity_purchased`,`recipient_name`,`ship_address_1`,`ship_address_2`,`ship_address_3`,`ship_state`,`ship_postal_code`,`ship_country`,`account`,`ship_city`,`cancel_order`,`delivery_areas`,`logistics_number`,`logistics_company`)VALUES ('$maxnum','$or_id','$or_it', '$shipments', '$payments_date','$buyer_email', '$buyer_name','$buyer_phone','$sku' ,'$jj_sku', '$product_name', '$quantity', '$recipient_name', '$ship_address1', '$ship_address2','$ship_address3','$ship_state' , '$ship_postal', '$ship_country', '$zhanghao', '$ship_city','$cancel_order','$delivery_areas','$logistics_number','$logistics_company')";
详细解决方案
反复写入数据库之后,同样的查询语句却查询不出结果
热度:57 发布时间:2016-04-28 21:24:59.0
相关解决方案