영카트 주문내역 에서 엑셀파일 저장해보기
adm/shop_admin/orderlist.php 주문내역 처리파일에서 버튼을 추가 해보세요
전체 주문내역 이부분바로 아래 에
<a href="./orderlist_excel.php?<?php echo $qstr1; ?>" class="ov_a">주문엑셀다운로드</a>
이렇게 추가해주시고
orderlist_excel.php 파일생성하시고 아래 복사하여 엑셀 헤더 파일을 정의해주세요
테스트는 5.6.26 버전 확인되었습니다.
<?php
include_once('./_common.php');
auth_check_menu($auth, '400400', "r");
// 검색조건 동일 적용
$where = array();
$od_status = isset($_GET['od_status']) ? $_GET['od_status'] : '';
$search = isset($_GET['search']) ? $_GET['search'] : '';
$sel_field = isset($_GET['sel_field']) ? $_GET['sel_field'] : '';
if ($search && $sel_field) {
$where[] = " $sel_field like '%$search%' ";
}
if ($od_status) {
$where[] = " od_status = '$od_status' ";
}
$sql_search = "";
if ($where) {
$sql_search = " where ".implode(" and ", $where);
}
$sql = "
select
od_id,
mb_id,
od_name,
od_tel,
od_hp,
od_receipt_price,
od_status,
od_time
from {$g5['g5_shop_order_table']}
$sql_search
order by od_id desc
";
$result = sql_query($sql);
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=orderlist_".date("Ymd").".xls");
header("Content-Description: PHP Generated Data");
echo "\xEF\xBB\xBF"; // 한글 깨짐 방지
echo "<table border='1'>";
echo "
<tr>
<th>주문번호</th>
<th>회원ID</th>
<th>주문자</th>
<th>전화</th>
<th>휴대폰</th>
<th>결제금액</th>
<th>주문상태</th>
<th>주문일시</th>
</tr>
";
while($row = sql_fetch_array($result)) {
echo "<tr>";
echo "<td>{$row['od_id']}</td>";
echo "<td>{$row['mb_id']}</td>";
echo "<td>{$row['od_name']}</td>";
echo "<td>{$row['od_tel']}</td>";
echo "<td>{$row['od_hp']}</td>";
echo "<td>{$row['od_receipt_price']}</td>";
echo "<td>{$row['od_status']}</td>";
echo "<td>{$row['od_time']}</td>";
echo "</tr>";
}
echo "</table>";
?>
전체 주문내역 이부분바로 아래 에
<a href="./orderlist_excel.php?<?php echo $qstr1; ?>" class="ov_a">주문엑셀다운로드</a>
이렇게 추가해주시고
orderlist_excel.php 파일생성하시고 아래 복사하여 엑셀 헤더 파일을 정의해주세요
테스트는 5.6.26 버전 확인되었습니다.
<?php
include_once('./_common.php');
auth_check_menu($auth, '400400', "r");
// 검색조건 동일 적용
$where = array();
$od_status = isset($_GET['od_status']) ? $_GET['od_status'] : '';
$search = isset($_GET['search']) ? $_GET['search'] : '';
$sel_field = isset($_GET['sel_field']) ? $_GET['sel_field'] : '';
if ($search && $sel_field) {
$where[] = " $sel_field like '%$search%' ";
}
if ($od_status) {
$where[] = " od_status = '$od_status' ";
}
$sql_search = "";
if ($where) {
$sql_search = " where ".implode(" and ", $where);
}
$sql = "
select
od_id,
mb_id,
od_name,
od_tel,
od_hp,
od_receipt_price,
od_status,
od_time
from {$g5['g5_shop_order_table']}
$sql_search
order by od_id desc
";
$result = sql_query($sql);
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=orderlist_".date("Ymd").".xls");
header("Content-Description: PHP Generated Data");
echo "\xEF\xBB\xBF"; // 한글 깨짐 방지
echo "<table border='1'>";
echo "
<tr>
<th>주문번호</th>
<th>회원ID</th>
<th>주문자</th>
<th>전화</th>
<th>휴대폰</th>
<th>결제금액</th>
<th>주문상태</th>
<th>주문일시</th>
</tr>
";
while($row = sql_fetch_array($result)) {
echo "<tr>";
echo "<td>{$row['od_id']}</td>";
echo "<td>{$row['mb_id']}</td>";
echo "<td>{$row['od_name']}</td>";
echo "<td>{$row['od_tel']}</td>";
echo "<td>{$row['od_hp']}</td>";
echo "<td>{$row['od_receipt_price']}</td>";
echo "<td>{$row['od_status']}</td>";
echo "<td>{$row['od_time']}</td>";
echo "</tr>";
}
echo "</table>";
?>
첨부파일
총 1명이 반응했습니다
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 3개
주문엑셀다운로드 추가못했습니다 ㅜㅜ 내용은 첨부파일 확인하시고요 회신부탁드립니다
<a href="./orderlist_excel.php?<?php echo $qstr1; ?>" class="ov_a">주문엑셀다운로드</a>
이부분추가하면 추가할 입구는 어디있나요
추가입구 보내주시고요
추가 입구 방법 그림으로 첨부파일로 보내주세요 감사합니다 수고하세요
그리고 다음
adm/shop_admin/orderlist_excel.php 이파일은 존재하지않습니다. 새로 생성하시고 위 코드 복사해서 저장하고업로드 해주셔야합니다.