PHP 엑셀 ( xls 또는 xlxs ) 파일 업로드 하여 DB 저장
페이지 정보
본문
그누보드5에 포함된 엑셀 함수를 이용해서 엑셀(Excel)의 xls 또는 xlsx 형식으로 파일 업로드하고 디비에 저장하는 방법입니다
그누보드(영카트)의 상품일괄등록 파일을 참고해서 만들었습니다
1. 폴더 구조
adm
└ shop_admin
└ itemexcelupdate.php
excel
├ _common.php
├ excel.css
├ excel_file.php 첨부파일 선택
├ excel_read.php 디비에 저장
└ excel_sample.php 엑셀샘플파일
lib
├ Excel ... 그누보드에서 배포되는 폴더
2. excel_file.php
<?php
include_once("_common.php");
if($member['mb_level']<'10') {
alert('로그인후 이용해주세요');
}
$g5['title'] = '엑셀파일로 상품 일괄 등록';
include_once(G5_PATH.'/head.php');
add_stylesheet('<link rel="stylesheet" href="./excel.css">', 0);
?>
<!--link rel="stylesheet" href="./excel.css"-->
<div class="new_win">
<h1><?php echo $g5['title']; ?></h1>
<div class="local_desc01 local_desc">
<p>
엑셀파일을 이용하여 상품을 일괄등록할 수 있습니다.<br>
형식은 <strong>상품일괄등록용 엑셀파일</strong>을 다운로드하여 상품 정보를 입력하시면 됩니다.<br>
수정 완료 후 엑셀파일을 업로드하시면 상품이 일괄등록됩니다.<br>
<!--엑셀파일을 저장하실 때는 <strong>Excel 97 - 2003 통합문서 (*.xls)</strong> 로 저장하셔야 합니다.-->
</p>
<p>
<a href="./excel_sample.xlsx">상품일괄등록용 엑셀파일 다운로드</a>
</p>
</div>
<form name="fitemexcel" method="post" action="./excel_read.php" enctype="MULTIPART/FORM-DATA" autocomplete="off">
<div id="excelfile_upload">
<label for="excelfile">파일선택</label>
<input type="file" name="excelfile" id="excelfile">
</div>
<div class="win_btn btn_confirm">
<input type="submit" value="상품 엑셀파일 등록" class="btn_submit btn">
<!--button type="button" onclick="window.close();" class="btn_close btn">닫기</button-->
</div>
</form>
</div>
<?php
include_once(G5_PATH.'/tail.php');
3. excel_read.php
<?php
include_once("_common.php");
if($member['mb_level']<'10') {
alert('로그인후 이용해주세요');
}
$g5['title'] = '상품 엑셀일괄등록 결과';
include_once(G5_PATH.'/head.php');
//$mysql_host = "localhost";
//$mysql_user = "아이디";
//$mysql_password = "비밀번호";
//$mysql_db = "데이타베이스";
//$dbconn = mysqli_connect($mysql_host,$mysql_user,$mysql_password,$mysql_db);
//$dbconn = mysqli_connect(G5_MYSQL_HOST,G5_MYSQL_USER,G5_MYSQL_PASSWORD,G5_MYSQL_DB);
//mysqli_query("set names utf8");
$is_upload_file = (isset($_FILES['excelfile']['tmp_name']) && $_FILES['excelfile']['tmp_name']) ? 1 : 0;
if( ! $is_upload_file){
alert("엑셀 파일을 업로드해 주세요.");
}
//echo " 엑셀 업로드 시작";
//exit;
// 저장될 디비 테이블
$save_dbtable = '';
if($is_upload_file) {
$file = $_FILES['excelfile']['tmp_name'];
//echo "file2 = {$file}<br>";
include_once(G5_LIB_PATH.'/PHPExcel/IOFactory.php');
$objPHPExcel = PHPExcel_IOFactory::load($file);
$sheet = $objPHPExcel->getSheet(0); // 첫번째 시트 데이타 추출
$num_rows = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$dup_it_id = array();
$fail_it_id = array();
$dup_count = 0;
$total_count = 0;
$fail_count = 0;
$succ_count = 0;
$item_date_up = date('Y-m-d H:i:s');
// 실 데이타가 3번행부터 시작되므로 $i = 3
for ($i = 3; $i <= $num_rows; $i++) {
$total_count++;
$j = 0;
$rowData = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i,
NULL,
TRUE,
FALSE);
// 사용하고자 하는 컬럼을 보여줍니다
$columnA = addslashes($rowData[0][$j++]);
$columnB = addslashes($rowData[0][$j++]);
$columnC = addslashes($rowData[0][$j++]);
$columnD = addslashes($rowData[0][$j++]);
$columnE = addslashes($rowData[0][$j++]);
$columnF = addslashes($rowData[0][$j++]);
$columnG = addslashes($rowData[0][$j++]);
$columnH = addslashes($rowData[0][$j++]);
$columnI = addslashes($rowData[0][$j++]);
$columnJ = addslashes($rowData[0][$j++]);
$columnK = addslashes($rowData[0][$j++]);
$columnL = addslashes($rowData[0][$j++]);
$columnM = addslashes($rowData[0][$j++]);
$columnN = addslashes($rowData[0][$j++]);
$columnO = addslashes($rowData[0][$j++]);
$columnP = addslashes($rowData[0][$j++]);
$columnQ = addslashes($rowData[0][$j++]);
$columnR = addslashes($rowData[0][$j++]);
$columnS = addslashes($rowData[0][$j++]);
$columnT = addslashes($rowData[0][$j++]);
$columnU = addslashes($rowData[0][$j++]);
$columnV = addslashes($rowData[0][$j++]);
$columnW = addslashes($rowData[0][$j++]);
$columnX = addslashes($rowData[0][$j++]);
$columnY = addslashes($rowData[0][$j++]);
$columnZ = addslashes($rowData[0][$j++]);
$columnAA = addslashes($rowData[0][$j++]);
$columnAB = addslashes($rowData[0][$j++]);
$columnAC = addslashes($rowData[0][$j++]);
$columnAD = addslashes($rowData[0][$j++]);
$columnAE = addslashes($rowData[0][$j++]);
$columnAF = addslashes($rowData[0][$j++]);
// 중복을 확인하는 컬럼
$dup_check = $columnB;
// 필드에 값이 있는지 확인해서 있을때만 작업시작
if ($dup_check) {
// $dup_check 중복체크
$sql = " select count(*) as cnt from `{$save_dbtable}` where 중복확인컬럼 = '{$dup_check}' ";
$row = sql_fetch($sql);
if(isset($row['cnt']) && $row['cnt']) {
$fail_it_id[] = $dup_check;
$dup_it_id[] = $dup_check;
$sql2 = " select * from `{$save_dbtable}` where 중복확인컬럼 = '{$dup_check}' ";
$row2 = sql_fetch_array(sql_query($sql2));
//echo "sql2 = ".$sql2."<br>";
// 변경된 값이 있는지 확인해서 있을때만 update 문 작동
if ($row2['컬럼A'] != $columnA || $row2['컬럼B'] != $columnB) {
$sql3 = " update `{$save_dbtable}` set ";
$sql3 .= " 컬럼A = '{$columnA}' ";
$sql3 .= " , 컬럼B = '{$columnB}' ";
$sql3 .= " , 컬럼C = '{$columnC}' ";
$sql3 .= " , 컬럼D = '{$columnD}' ";
$sql3 .= " , 컬럼E = '{$columnE}' ";
$sql3 .= " , 컬럼F = '{$columnF}' ";
$sql3 .= " , 컬럼G = '{$columnG}' ";
$sql3 .= " , 컬럼H = '{$columnH}' ";
$sql3 .= " , 컬럼I = '{$columnI}' ";
$sql3 .= " , 컬럼J = '{$columnJ}' ";
$sql3 .= " , 컬럼K = '{$columnK}' ";
$sql3 .= " , 컬럼L = '{$columnL}' ";
$sql3 .= " , 컬럼M = '{$columnM}' ";
$sql3 .= " , 컬럼N = '{$columnN}' ";
$sql3 .= " , 컬럼O = '{$columnO}' ";
$sql3 .= " , 컬럼P = '{$columnP}' ";
$sql3 .= " , 컬럼Q = '{$columnQ}' ";
$sql3 .= " , 컬럼R = '{$columnR}' ";
$sql3 .= " , 컬럼S = '{$columnS}' ";
$sql3 .= " , 컬럼T = '{$columnT}' ";
$sql3 .= " , 컬럼U = '{$columnU}' ";
$sql3 .= " , 컬럼V = '{$columnV}' ";
$sql3 .= " , 컬럼W = '{$columnW}' ";
$sql3 .= " , 컬럼X = '{$columnX}' ";
$sql3 .= " , 컬럼Y = '{$columnY}' ";
$sql3 .= " , 컬럼Z = '{$columnZ}' ";
$sql3 .= " , 컬럼AA = '{$columnAA}' ";
$sql3 .= " , 컬럼AB = '{$columnAB}' ";
$sql3 .= " , 컬럼AC = '{$columnAC}' ";
$sql3 .= " , 컬럼AD = '{$columnAD}' ";
$sql3 .= " , 컬럼AE = '{$columnAE}' ";
$sql3 .= " , 컬럼AF = '{$columnAF}' ";
$sql3 .= " where 중복확인컬럼 = '{$dup_check}' ";
//mysqli_query($dbconn, $sql3);
sql_query($sql3);
//echo "sql3 = {$sql3}<br>";
}
$dup_count++;
$fail_count++;
continue;
} else {
$sql3 = " insert into `{$save_dbtable}` set ";
$sql3 .= " 컬럼A = '{$columnA}' ";
$sql3 .= " , 컬럼B = '{$columnB}' ";
$sql3 .= " , 컬럼C = '{$columnC}' ";
$sql3 .= " , 컬럼D = '{$columnD}' ";
$sql3 .= " , 컬럼E = '{$columnE}' ";
$sql3 .= " , 컬럼F = '{$columnF}' ";
$sql3 .= " , 컬럼G = '{$columnG}' ";
$sql3 .= " , 컬럼H = '{$columnH}' ";
$sql3 .= " , 컬럼I = '{$columnI}' ";
$sql3 .= " , 컬럼J = '{$columnJ}' ";
$sql3 .= " , 컬럼K = '{$columnK}' ";
$sql3 .= " , 컬럼L = '{$columnL}' ";
$sql3 .= " , 컬럼M = '{$columnM}' ";
$sql3 .= " , 컬럼N = '{$columnN}' ";
$sql3 .= " , 컬럼O = '{$columnO}' ";
$sql3 .= " , 컬럼P = '{$columnP}' ";
$sql3 .= " , 컬럼Q = '{$columnQ}' ";
$sql3 .= " , 컬럼R = '{$columnR}' ";
$sql3 .= " , 컬럼S = '{$columnS}' ";
$sql3 .= " , 컬럼T = '{$columnT}' ";
$sql3 .= " , 컬럼U = '{$columnU}' ";
$sql3 .= " , 컬럼V = '{$columnV}' ";
$sql3 .= " , 컬럼W = '{$columnW}' ";
$sql3 .= " , 컬럼X = '{$columnX}' ";
$sql3 .= " , 컬럼Y = '{$columnY}' ";
$sql3 .= " , 컬럼Z = '{$columnZ}' ";
$sql3 .= " , 컬럼AA = '{$columnAA}' ";
$sql3 .= " , 컬럼AB = '{$columnAB}' ";
$sql3 .= " , 컬럼AC = '{$columnAC}' ";
$sql3 .= " , 컬럼AD = '{$columnAD}' ";
$sql3 .= " , 컬럼AE = '{$columnAE}' ";
$sql3 .= " , 컬럼AF = '{$columnAF}' ";
//mysqli_query($dbconn, $sql3);
sql_query($sql3);
//echo "sql3 = {$sql3}<br>";
$succ_count++;
}
}
}
}
add_stylesheet('<link rel="stylesheet" href="./excel.css">', 0);
?>
<!--link rel="stylesheet" href="./excel.css"-->
<div class="new_win">
<h1><?php echo $g5['title']; ?></h1>
<div class="local_desc01 local_desc">
<p>상품등록을 완료했습니다.</p>
</div>
<dl id="excelfile_result">
<dt>총상품수</dt>
<dd><?php echo number_format($total_count); ?></dd>
<dt>완료건수</dt>
<dd><?php echo number_format($succ_count); ?></dd>
<?php /* ?>
<dt>실패건수</dt>
<dd><?php echo number_format($fail_count); ?></dd>
<?php if($fail_count > 0) { ?>
<dt>실패상품코드</dt>
<dd><?php //echo implode(', ', $fail_it_id); ?></dd>
<?php } ?
<?php */ ?>
<?php if($dup_count > 0) { ?>
<dt>상품코드중복건수</dt>
<dd><?php echo number_format($dup_count); ?></dd>
<?php /* ?>
<dt>중복상품코드</dt>
<dd><?php echo implode(', ', $dup_it_id); ?></dd>
<?php */ ?>
<?php } ?>
</dl>
<!--div class="btn_win01 btn_win">
<button type="button" onclick="window.close();">창닫기</button>
</div-->
</div>
<?php
include_once(G5_PATH.'/tail.php');
4. excel.css
@charset "utf-8";
/* 초기화 */
html {overflow-y:scroll}
body {margin:0;padding:0;font-size:0.75em;height:100%;}
html, h1, h2, h3, h4, h5, h6, form, fieldset, img {margin:0;padding:0;border:0}
h1, h2, h3, h4, h5, h6 {font-size:1em;}
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {display:block}
/* 새창 */
.new_win table {width:100%}
.new_win .win_btn {clear:both;padding:10px;text-align:center} /* 새창용 */
.new_win .win_btn button {display:inline-block;padding:0 10px;height:30px;border:0;line-height:2em;cursor:pointer}
.new_win .win_btn input {padding:0 10px;height:30px;line-height:2em}
.new_win .win_btn a {display:inline-block;padding:0 10px;height:30px;background:#4b545e;color:#fff;vertical-align:middle;line-height:2.4em}
.new_win .win_btn a:focus, .new_win .win_btn a:hover {text-decoration:none}
.new_win .btn_confirm {text-align:center;}
/* 새창 기본 스타일 */
.new_win {}
.new_win h1 {font-size:1.17em;padding:15px 20px;background:#fff;border-bottom:1px solid #ddd}
.new_win h2 {margin:0 20px 10px}
.new_win_ul {margin:-20px 0 20px 0;padding:0 0 0 20px;border-bottom:1px solid #515151;background:#484848;list-style:none;zoom:1}
.new_win_ul:after {display:block;visibility:hidden;clear:both;content:""}
.new_win_ul li {float:left;margin-left:-1px}
.new_win_ul a {display:block;padding:10px 10px 8px;border-right:1px solid #595959;border-left:1px solid #595959;color:#fff;font-family:dotum;font-weight:bold;text-decoration:none}
.new_win_desc {margin:0 }
.new_win .anchor {margin:0 0 5px}
.new_win .win_btn {clear:both;padding:10px;text-align:center} /* 새창용 */
.new_win .win_btn button {display:inline-block;padding:0 10px;height:30px;border:0;line-height:2em;cursor:pointer}
.new_win .win_btn input {padding:0 10px;height:30px;line-height:2em}
.new_win .win_btn a {display:inline-block;padding:0 10px;height:30px;background:#4b545e;color:#fff;vertical-align:middle;line-height:2.4em}
.new_win .win_btn a:focus, .new_win .win_btn a:hover {text-decoration:none}
.new_win .local_sch, .new_win .local_cmd, .new_win .local_desc01, .new_win .local_desc02, .new_win .local_ov {margin:10px}
.new_win_con{margin: 10px; background:#fff;padding:20px}
.new_win_con .table_form table th{width:120px}
.new_win .btn_confirm {text-align:center;}
/* 페이지 내 안내문 */
.local_desc {background:#eaeaea;padding:10px 20px;margin:10px 0;line-height:1.5em }
.local_desc ol, .local_desc ul {margin:0;padding:0 0 0 10px}
.local_desc strong{color:red}
.local_desc li{margin:10px 0}
.local_wr{margin:0 0 10px }
.local_wr:after{display:block;visibility:hidden;clear:both;content:""}
.local_desc01 {margin:10px 0 10px ;padding:10px 20px;border:1px solid #f2f2f2;background:#f9f9f9}
.local_desc01 strong {color:#ff3061}
.local_desc01 a {text-decoration:underline}
.local_desc02 {margin:10px 0 ;min-width:960px} /* 주로 온라인 서식 관련 안내 내용에 사용 */
.local_desc02 p {padding:0;line-height:1.8em}
.new_win .local_sch, .new_win .local_cmd, .new_win .local_desc01, .new_win .local_desc02, .new_win .local_ov {margin:10px}
.btn_win {margin:0 20px 10px} /* 새창용 */
.btn_win01 {clear:both;text-align:center}
.btn_win01 a, .btn_win01 button {padding:0 10px;height:22px;border:1px solid #ccc;background:#fafafa}
.btn_win01 a {display:inline-block;line-height:2em;cursor:pointer}
.btn_win01 a:focus, .btn_win01 a:hover {text-decoration:none}
/* 상품 일괄 등록 */
#excelfile_upload {margin:10px ;padding:20px;border:1px solid #e9e9e9;background:#fff}
#excelfile_upload label {font-weight:bold}
#excelfile_input {margin:0 0 20px;text-align:center}
#excelfile_result {margin:0 20px 20px;border-bottom:1px solid #e9e9e9;zoom:1}
#excelfile_result:after {display:block;visibility:hidden;clear:both;content:""}
#excelfile_result dt {clear:both;float:left;padding:10px 0;width:40%;font-weight:bold}
#excelfile_result dd {float:left;margin:0;padding:10px 0;width:60%}
#excelfile_result .result_done {color:#5d910b}
#excelfile_result .result_fail {color:#ff3061}
그누보드(영카트)의 상품일괄등록 파일을 참고해서 만들었습니다
1. 폴더 구조
adm
└ shop_admin
└ itemexcelupdate.php
excel
├ _common.php
├ excel.css
├ excel_file.php 첨부파일 선택
├ excel_read.php 디비에 저장
└ excel_sample.php 엑셀샘플파일
lib
├ Excel ... 그누보드에서 배포되는 폴더
2. excel_file.php
<?php
include_once("_common.php");
if($member['mb_level']<'10') {
alert('로그인후 이용해주세요');
}
$g5['title'] = '엑셀파일로 상품 일괄 등록';
include_once(G5_PATH.'/head.php');
add_stylesheet('<link rel="stylesheet" href="./excel.css">', 0);
?>
<!--link rel="stylesheet" href="./excel.css"-->
<div class="new_win">
<h1><?php echo $g5['title']; ?></h1>
<div class="local_desc01 local_desc">
<p>
엑셀파일을 이용하여 상품을 일괄등록할 수 있습니다.<br>
형식은 <strong>상품일괄등록용 엑셀파일</strong>을 다운로드하여 상품 정보를 입력하시면 됩니다.<br>
수정 완료 후 엑셀파일을 업로드하시면 상품이 일괄등록됩니다.<br>
<!--엑셀파일을 저장하실 때는 <strong>Excel 97 - 2003 통합문서 (*.xls)</strong> 로 저장하셔야 합니다.-->
</p>
<p>
<a href="./excel_sample.xlsx">상품일괄등록용 엑셀파일 다운로드</a>
</p>
</div>
<form name="fitemexcel" method="post" action="./excel_read.php" enctype="MULTIPART/FORM-DATA" autocomplete="off">
<div id="excelfile_upload">
<label for="excelfile">파일선택</label>
<input type="file" name="excelfile" id="excelfile">
</div>
<div class="win_btn btn_confirm">
<input type="submit" value="상품 엑셀파일 등록" class="btn_submit btn">
<!--button type="button" onclick="window.close();" class="btn_close btn">닫기</button-->
</div>
</form>
</div>
<?php
include_once(G5_PATH.'/tail.php');
3. excel_read.php
<?php
include_once("_common.php");
if($member['mb_level']<'10') {
alert('로그인후 이용해주세요');
}
$g5['title'] = '상품 엑셀일괄등록 결과';
include_once(G5_PATH.'/head.php');
//$mysql_host = "localhost";
//$mysql_user = "아이디";
//$mysql_password = "비밀번호";
//$mysql_db = "데이타베이스";
//$dbconn = mysqli_connect($mysql_host,$mysql_user,$mysql_password,$mysql_db);
//$dbconn = mysqli_connect(G5_MYSQL_HOST,G5_MYSQL_USER,G5_MYSQL_PASSWORD,G5_MYSQL_DB);
//mysqli_query("set names utf8");
$is_upload_file = (isset($_FILES['excelfile']['tmp_name']) && $_FILES['excelfile']['tmp_name']) ? 1 : 0;
if( ! $is_upload_file){
alert("엑셀 파일을 업로드해 주세요.");
}
//echo " 엑셀 업로드 시작";
//exit;
// 저장될 디비 테이블
$save_dbtable = '';
if($is_upload_file) {
$file = $_FILES['excelfile']['tmp_name'];
//echo "file2 = {$file}<br>";
include_once(G5_LIB_PATH.'/PHPExcel/IOFactory.php');
$objPHPExcel = PHPExcel_IOFactory::load($file);
$sheet = $objPHPExcel->getSheet(0); // 첫번째 시트 데이타 추출
$num_rows = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$dup_it_id = array();
$fail_it_id = array();
$dup_count = 0;
$total_count = 0;
$fail_count = 0;
$succ_count = 0;
$item_date_up = date('Y-m-d H:i:s');
// 실 데이타가 3번행부터 시작되므로 $i = 3
for ($i = 3; $i <= $num_rows; $i++) {
$total_count++;
$j = 0;
$rowData = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i,
NULL,
TRUE,
FALSE);
// 사용하고자 하는 컬럼을 보여줍니다
$columnA = addslashes($rowData[0][$j++]);
$columnB = addslashes($rowData[0][$j++]);
$columnC = addslashes($rowData[0][$j++]);
$columnD = addslashes($rowData[0][$j++]);
$columnE = addslashes($rowData[0][$j++]);
$columnF = addslashes($rowData[0][$j++]);
$columnG = addslashes($rowData[0][$j++]);
$columnH = addslashes($rowData[0][$j++]);
$columnI = addslashes($rowData[0][$j++]);
$columnJ = addslashes($rowData[0][$j++]);
$columnK = addslashes($rowData[0][$j++]);
$columnL = addslashes($rowData[0][$j++]);
$columnM = addslashes($rowData[0][$j++]);
$columnN = addslashes($rowData[0][$j++]);
$columnO = addslashes($rowData[0][$j++]);
$columnP = addslashes($rowData[0][$j++]);
$columnQ = addslashes($rowData[0][$j++]);
$columnR = addslashes($rowData[0][$j++]);
$columnS = addslashes($rowData[0][$j++]);
$columnT = addslashes($rowData[0][$j++]);
$columnU = addslashes($rowData[0][$j++]);
$columnV = addslashes($rowData[0][$j++]);
$columnW = addslashes($rowData[0][$j++]);
$columnX = addslashes($rowData[0][$j++]);
$columnY = addslashes($rowData[0][$j++]);
$columnZ = addslashes($rowData[0][$j++]);
$columnAA = addslashes($rowData[0][$j++]);
$columnAB = addslashes($rowData[0][$j++]);
$columnAC = addslashes($rowData[0][$j++]);
$columnAD = addslashes($rowData[0][$j++]);
$columnAE = addslashes($rowData[0][$j++]);
$columnAF = addslashes($rowData[0][$j++]);
// 중복을 확인하는 컬럼
$dup_check = $columnB;
// 필드에 값이 있는지 확인해서 있을때만 작업시작
if ($dup_check) {
// $dup_check 중복체크
$sql = " select count(*) as cnt from `{$save_dbtable}` where 중복확인컬럼 = '{$dup_check}' ";
$row = sql_fetch($sql);
if(isset($row['cnt']) && $row['cnt']) {
$fail_it_id[] = $dup_check;
$dup_it_id[] = $dup_check;
$sql2 = " select * from `{$save_dbtable}` where 중복확인컬럼 = '{$dup_check}' ";
$row2 = sql_fetch_array(sql_query($sql2));
//echo "sql2 = ".$sql2."<br>";
// 변경된 값이 있는지 확인해서 있을때만 update 문 작동
if ($row2['컬럼A'] != $columnA || $row2['컬럼B'] != $columnB) {
$sql3 = " update `{$save_dbtable}` set ";
$sql3 .= " 컬럼A = '{$columnA}' ";
$sql3 .= " , 컬럼B = '{$columnB}' ";
$sql3 .= " , 컬럼C = '{$columnC}' ";
$sql3 .= " , 컬럼D = '{$columnD}' ";
$sql3 .= " , 컬럼E = '{$columnE}' ";
$sql3 .= " , 컬럼F = '{$columnF}' ";
$sql3 .= " , 컬럼G = '{$columnG}' ";
$sql3 .= " , 컬럼H = '{$columnH}' ";
$sql3 .= " , 컬럼I = '{$columnI}' ";
$sql3 .= " , 컬럼J = '{$columnJ}' ";
$sql3 .= " , 컬럼K = '{$columnK}' ";
$sql3 .= " , 컬럼L = '{$columnL}' ";
$sql3 .= " , 컬럼M = '{$columnM}' ";
$sql3 .= " , 컬럼N = '{$columnN}' ";
$sql3 .= " , 컬럼O = '{$columnO}' ";
$sql3 .= " , 컬럼P = '{$columnP}' ";
$sql3 .= " , 컬럼Q = '{$columnQ}' ";
$sql3 .= " , 컬럼R = '{$columnR}' ";
$sql3 .= " , 컬럼S = '{$columnS}' ";
$sql3 .= " , 컬럼T = '{$columnT}' ";
$sql3 .= " , 컬럼U = '{$columnU}' ";
$sql3 .= " , 컬럼V = '{$columnV}' ";
$sql3 .= " , 컬럼W = '{$columnW}' ";
$sql3 .= " , 컬럼X = '{$columnX}' ";
$sql3 .= " , 컬럼Y = '{$columnY}' ";
$sql3 .= " , 컬럼Z = '{$columnZ}' ";
$sql3 .= " , 컬럼AA = '{$columnAA}' ";
$sql3 .= " , 컬럼AB = '{$columnAB}' ";
$sql3 .= " , 컬럼AC = '{$columnAC}' ";
$sql3 .= " , 컬럼AD = '{$columnAD}' ";
$sql3 .= " , 컬럼AE = '{$columnAE}' ";
$sql3 .= " , 컬럼AF = '{$columnAF}' ";
$sql3 .= " where 중복확인컬럼 = '{$dup_check}' ";
//mysqli_query($dbconn, $sql3);
sql_query($sql3);
//echo "sql3 = {$sql3}<br>";
}
$dup_count++;
$fail_count++;
continue;
} else {
$sql3 = " insert into `{$save_dbtable}` set ";
$sql3 .= " 컬럼A = '{$columnA}' ";
$sql3 .= " , 컬럼B = '{$columnB}' ";
$sql3 .= " , 컬럼C = '{$columnC}' ";
$sql3 .= " , 컬럼D = '{$columnD}' ";
$sql3 .= " , 컬럼E = '{$columnE}' ";
$sql3 .= " , 컬럼F = '{$columnF}' ";
$sql3 .= " , 컬럼G = '{$columnG}' ";
$sql3 .= " , 컬럼H = '{$columnH}' ";
$sql3 .= " , 컬럼I = '{$columnI}' ";
$sql3 .= " , 컬럼J = '{$columnJ}' ";
$sql3 .= " , 컬럼K = '{$columnK}' ";
$sql3 .= " , 컬럼L = '{$columnL}' ";
$sql3 .= " , 컬럼M = '{$columnM}' ";
$sql3 .= " , 컬럼N = '{$columnN}' ";
$sql3 .= " , 컬럼O = '{$columnO}' ";
$sql3 .= " , 컬럼P = '{$columnP}' ";
$sql3 .= " , 컬럼Q = '{$columnQ}' ";
$sql3 .= " , 컬럼R = '{$columnR}' ";
$sql3 .= " , 컬럼S = '{$columnS}' ";
$sql3 .= " , 컬럼T = '{$columnT}' ";
$sql3 .= " , 컬럼U = '{$columnU}' ";
$sql3 .= " , 컬럼V = '{$columnV}' ";
$sql3 .= " , 컬럼W = '{$columnW}' ";
$sql3 .= " , 컬럼X = '{$columnX}' ";
$sql3 .= " , 컬럼Y = '{$columnY}' ";
$sql3 .= " , 컬럼Z = '{$columnZ}' ";
$sql3 .= " , 컬럼AA = '{$columnAA}' ";
$sql3 .= " , 컬럼AB = '{$columnAB}' ";
$sql3 .= " , 컬럼AC = '{$columnAC}' ";
$sql3 .= " , 컬럼AD = '{$columnAD}' ";
$sql3 .= " , 컬럼AE = '{$columnAE}' ";
$sql3 .= " , 컬럼AF = '{$columnAF}' ";
//mysqli_query($dbconn, $sql3);
sql_query($sql3);
//echo "sql3 = {$sql3}<br>";
$succ_count++;
}
}
}
}
add_stylesheet('<link rel="stylesheet" href="./excel.css">', 0);
?>
<!--link rel="stylesheet" href="./excel.css"-->
<div class="new_win">
<h1><?php echo $g5['title']; ?></h1>
<div class="local_desc01 local_desc">
<p>상품등록을 완료했습니다.</p>
</div>
<dl id="excelfile_result">
<dt>총상품수</dt>
<dd><?php echo number_format($total_count); ?></dd>
<dt>완료건수</dt>
<dd><?php echo number_format($succ_count); ?></dd>
<?php /* ?>
<dt>실패건수</dt>
<dd><?php echo number_format($fail_count); ?></dd>
<?php if($fail_count > 0) { ?>
<dt>실패상품코드</dt>
<dd><?php //echo implode(', ', $fail_it_id); ?></dd>
<?php } ?
<?php */ ?>
<?php if($dup_count > 0) { ?>
<dt>상품코드중복건수</dt>
<dd><?php echo number_format($dup_count); ?></dd>
<?php /* ?>
<dt>중복상품코드</dt>
<dd><?php echo implode(', ', $dup_it_id); ?></dd>
<?php */ ?>
<?php } ?>
</dl>
<!--div class="btn_win01 btn_win">
<button type="button" onclick="window.close();">창닫기</button>
</div-->
</div>
<?php
include_once(G5_PATH.'/tail.php');
4. excel.css
@charset "utf-8";
/* 초기화 */
html {overflow-y:scroll}
body {margin:0;padding:0;font-size:0.75em;height:100%;}
html, h1, h2, h3, h4, h5, h6, form, fieldset, img {margin:0;padding:0;border:0}
h1, h2, h3, h4, h5, h6 {font-size:1em;}
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {display:block}
/* 새창 */
.new_win table {width:100%}
.new_win .win_btn {clear:both;padding:10px;text-align:center} /* 새창용 */
.new_win .win_btn button {display:inline-block;padding:0 10px;height:30px;border:0;line-height:2em;cursor:pointer}
.new_win .win_btn input {padding:0 10px;height:30px;line-height:2em}
.new_win .win_btn a {display:inline-block;padding:0 10px;height:30px;background:#4b545e;color:#fff;vertical-align:middle;line-height:2.4em}
.new_win .win_btn a:focus, .new_win .win_btn a:hover {text-decoration:none}
.new_win .btn_confirm {text-align:center;}
/* 새창 기본 스타일 */
.new_win {}
.new_win h1 {font-size:1.17em;padding:15px 20px;background:#fff;border-bottom:1px solid #ddd}
.new_win h2 {margin:0 20px 10px}
.new_win_ul {margin:-20px 0 20px 0;padding:0 0 0 20px;border-bottom:1px solid #515151;background:#484848;list-style:none;zoom:1}
.new_win_ul:after {display:block;visibility:hidden;clear:both;content:""}
.new_win_ul li {float:left;margin-left:-1px}
.new_win_ul a {display:block;padding:10px 10px 8px;border-right:1px solid #595959;border-left:1px solid #595959;color:#fff;font-family:dotum;font-weight:bold;text-decoration:none}
.new_win_desc {margin:0 }
.new_win .anchor {margin:0 0 5px}
.new_win .win_btn {clear:both;padding:10px;text-align:center} /* 새창용 */
.new_win .win_btn button {display:inline-block;padding:0 10px;height:30px;border:0;line-height:2em;cursor:pointer}
.new_win .win_btn input {padding:0 10px;height:30px;line-height:2em}
.new_win .win_btn a {display:inline-block;padding:0 10px;height:30px;background:#4b545e;color:#fff;vertical-align:middle;line-height:2.4em}
.new_win .win_btn a:focus, .new_win .win_btn a:hover {text-decoration:none}
.new_win .local_sch, .new_win .local_cmd, .new_win .local_desc01, .new_win .local_desc02, .new_win .local_ov {margin:10px}
.new_win_con{margin: 10px; background:#fff;padding:20px}
.new_win_con .table_form table th{width:120px}
.new_win .btn_confirm {text-align:center;}
/* 페이지 내 안내문 */
.local_desc {background:#eaeaea;padding:10px 20px;margin:10px 0;line-height:1.5em }
.local_desc ol, .local_desc ul {margin:0;padding:0 0 0 10px}
.local_desc strong{color:red}
.local_desc li{margin:10px 0}
.local_wr{margin:0 0 10px }
.local_wr:after{display:block;visibility:hidden;clear:both;content:""}
.local_desc01 {margin:10px 0 10px ;padding:10px 20px;border:1px solid #f2f2f2;background:#f9f9f9}
.local_desc01 strong {color:#ff3061}
.local_desc01 a {text-decoration:underline}
.local_desc02 {margin:10px 0 ;min-width:960px} /* 주로 온라인 서식 관련 안내 내용에 사용 */
.local_desc02 p {padding:0;line-height:1.8em}
.new_win .local_sch, .new_win .local_cmd, .new_win .local_desc01, .new_win .local_desc02, .new_win .local_ov {margin:10px}
.btn_win {margin:0 20px 10px} /* 새창용 */
.btn_win01 {clear:both;text-align:center}
.btn_win01 a, .btn_win01 button {padding:0 10px;height:22px;border:1px solid #ccc;background:#fafafa}
.btn_win01 a {display:inline-block;line-height:2em;cursor:pointer}
.btn_win01 a:focus, .btn_win01 a:hover {text-decoration:none}
/* 상품 일괄 등록 */
#excelfile_upload {margin:10px ;padding:20px;border:1px solid #e9e9e9;background:#fff}
#excelfile_upload label {font-weight:bold}
#excelfile_input {margin:0 0 20px;text-align:center}
#excelfile_result {margin:0 20px 20px;border-bottom:1px solid #e9e9e9;zoom:1}
#excelfile_result:after {display:block;visibility:hidden;clear:both;content:""}
#excelfile_result dt {clear:both;float:left;padding:10px 0;width:40%;font-weight:bold}
#excelfile_result dd {float:left;margin:0;padding:10px 0;width:60%}
#excelfile_result .result_done {color:#5d910b}
#excelfile_result .result_fail {color:#ff3061}
댓글목록
등록된 댓글이 없습니다.