将Excel行数据获取到php中的mysql列 [英] Getting Excel row data to mysql column in php

查看:81
本文介绍了将Excel行数据获取到php中的mysql列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用php从excel到mysql获取数据.请查看下面的excel图表:

I know how I can get data from excel to mysql using php. Please have look at the excel chart below:

我想在下面的mysql表中输入数据. 从excel文件列中,D,E,F,G数据将作为行插入mysql表& A,B,C列H将输入为列,但将在行号之后为A,B,C& D

I want to input data in below mysql table. From the excel file column D,E,F,G data will insert as row in mysql table & column A,B,C & H will input as column but will follow the no of row as A,B,C & D

我觉得我要问的有点复杂.但是,请尝试给出一些想法或建议如何做.我无法更改excel文件,因为有许多文件可以通过这种方式进行.

I feel what I'm asking is a bit complicated. But please try to give some idea or advise on how to do that. I can't change the excel file, because there are many files to proceed this way.

推荐答案

下面是代码,现在很好.

Here below the code,its fine now.

$fft1=888;
$fft2=777;
$fft3="";
$fft4=999;

$fft5=100;
$ctnqty=10;
$friendslist = "$fft1,$fft2,$fft3,$fft4";
$id = $fft5;
$friendarray = explode(",", $friendslist);
  $frienduserarray = array();

for ($n = 0; $n < count($friendarray); $n++) {
  $friendidpush = "('".$id."','".$friendarray[$n]."','".$ctnqty."'),";
  array_push($frienduserarray, $friendidpush);
 }
 $query = "INSERT INTO freddyhipment (style, orderno,ctnqty) VALUES ";
 $friendarray = explode(",", $friendslist);

 foreach ($friendarray as $order) {
$query .= "('" . $id . "','" . $order . "','" . $ctnqty . "'),";
}

$query = substr($query, 0, -1); // remove trailing comma

这篇关于将Excel行数据获取到php中的mysql列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆