2015. 3. 24. 16:43ㆍIT/PHP
// 파일첨부 내용 시작
<?
$sub_menu = "200900";
include_once("./_common.php");
auth_check($auth[$sub_menu], "r");
$g4[title] = "엑셀입력";
include_once("./admin.head.php");
?>
<script language="javascript" src="<?=$g4[path]?>/js/sideview.js"></script>
<script language="JavaScript">
var list_update_php = "member_list_update.php";
var list_delete_php = "member_list_delete.php";
</script>
<form name=forderprint action="./huwon_xls_update.php" method='post' enctype='multipart/form-data'>
<input type=hidden name=case value="2">
<table width=100%>
<tr><td colspan=2 height=2 bgcolor=#DDDDDD></td></tr>
<tr>
<td width="150" class="pad_t10">엑셀파일 업로드 <b>(*.csv)</b></td>
<td class="pad_tl10">
<input type=file name=fr_od_id size=30 maxlength=10 class=ed> <b>확장자를 csv로 저장 후 업로드해주세요.</b>
</td>
</tr>
<tr>
<td colspan=2><input type=submit class=btn1 value=' 확 인 '></td>
</tr>
</table>
</form>
<?
include_once ("./admin.tail.php");
?>
// 파일첨부 내용 끝
// 파일 읽기 시작
<?
setlocale(LC_CTYPE, 'ko_KR.eucKR');
$sub_menu = "200800";
include_once("./_common.php");
include_once("./admin.head.php");
$csvLoad = fopen($_FILES['fr_od_id']['tmp_name'],"r");
$i = 1;
while ( $minfo = fgetcsv( $csvLoad, 1000 ) ) {
print_r2($minfo);
$birth = "";
$hp = "";
$h_date = "";
$h_gbn = "";
$h_result = "";
$h_amt = "";
$h_pay = "";
$reg_date = "";
if($i > 1){
$birth = iconv("euc-kr","utf-8",$minfo[1]);
$hp = iconv("euc-kr","utf-8",$minfo[2]);
$h_date = iconv("euc-kr","utf-8",$minfo[3]);
$h_gbn = iconv("euc-kr","utf-8",$minfo[4]);
$h_result = iconv("euc-kr","utf-8",$minfo[5]);
$h_amt = iconv("euc-kr","utf-8",$minfo[6]);
$h_pay = iconv("euc-kr","utf-8",$minfo[7]);
$reg_date = $g4[time_ymdhis];
// 생일 자르기
$birth = substr(trim($birth), 0, 6);
$hp = trim(str_replace("-","",$hp));
$h_date = trim(str_replace("-","",$h_date));
$h_date = trim(str_replace(".","",$h_date));
$h_gbn = trim(str_replace(".","",$h_gbn));
$h_result = trim(str_replace(".","",$h_result));
$h_amt = trim(str_replace(",","",$h_amt));
$h_pay = (str_replace("원","",$h_pay));
$h_pay = (str_replace(",","",$h_pay));
$h_pay = (str_replace("\"","",$h_pay));
$sql = "select count(*) as cnt from g4_huwon where birth='$birth' and h_date = '$h_date' and hp = '$hp' ";
$row2 = sql_fetch($sql);
if($row2[cnt]>0){
$sql = "select * from g4_huwon where birth='$birth' and h_date = '$h_date' and hp = '$hp' limit 0, 1 ";
$row33 = sql_fetch($sql);
$sql=" update g4_huwon set
birth='$birth',
hp='$hp',
h_date='$h_date',
h_gbn='$h_gbn',
h_result='$h_result',
h_amt='$h_amt',
h_pay='$h_pay'
where h_idx='$row33[h_idx]'";
}else{
$sql=" insert into g4_huwon set
birth='$birth',
hp='$hp',
h_date='$h_date',
h_gbn='$h_gbn',
h_result='$h_result',
h_amt='$h_amt',
h_pay='$h_pay'
";
}
echo $sql."<BR><BR><BR>";
//sql_query($sql);
}
$i++;
}
//$csvArray = split("\n",implode($csvLoad));
$num=count($csvArray)-2;
die();
echo "{$num}건 변환 완료 되었습니다.";
echo "<br><input type='button' class=btn1 value='완료' onclick=\"location.href('$g4[path]/adm/member_list.php');\">";
include_once ("./admin.tail.php");
?>
// 파일 읽기 끝
'IT > PHP' 카테고리의 다른 글
날짜관련 (0) | 2015.03.24 |
---|---|
php mysql 연동, 연결 하기~~~ (0) | 2015.03.24 |
mysql random 함수로 select 및 update 하기 (0) | 2015.03.24 |
날짜관련함수 - 계속업데이트 (0) | 2015.03.24 |
php POST로 받은 값 모두 특정 폴더에 파일에다가 기록, 저장하기 (0) | 2015.03.24 |