테스트 사이트 - 개발 중인 베타 버전입니다

회원목록 엑셀다운로드

· 2년 전 · 3655 · 12

<?php
include_once('./_common.php');

auth_check_menu($auth, $sub_menu, 'r');

// 엑셀 다운로드 함수
function array_to_excel($data, $filename){
    header('Content-Type: application/vnd.ms-excel; charset=utf-8');
    header('Content-Disposition: attachment; filename="' . $filename . '.xls"');
    header('Cache-Control: max-age=0');
    $out = fopen('php://output', 'w');
    fputs($out, "\xEF\xBB\xBF"); // UTF-8 with BOM
    fputcsv($out, array_keys($data[0]), "\t");
    foreach ($data as $row) {
        fputcsv($out, $row, "\t");
    }
    fclose($out);
}

$sql_common = " from {$g5['member_table']} ";

$sql_search = " where (1) ";
if ($stx) {
    $sql_search .= " and ( ";
    switch ($sfl) {
        case 'mb_point' :
            $sql_search .= " ({$sfl} >= '{$stx}') ";
            break;
        case 'mb_level' :
            $sql_search .= " ({$sfl} = '{$stx}') ";
            break;
        case 'mb_tel' :
        case 'mb_hp' :
            $sql_search .= " ({$sfl} like '%{$stx}') ";
            break;
        default :
            $sql_search .= " ({$sfl} like '{$stx}%') ";
            break;
    }
    $sql_search .= " ) ";
}

if ($is_admin != 'super')
    $sql_search .= " and mb_level <= '{$member['mb_level']}' ";

if (!$sst) {
    $sst = "mb_datetime";
    $sod = "desc";
}

$sql_order = " order by {$sst} {$sod} ";

$sql = " select * {$sql_common} {$sql_search} {$sql_order} ";
$result = sql_query($sql);

// 테이블 출력을 위한 HTML 코드 추가
echo "<table border='1'>";
echo "<tr>";
echo "<th>번호</th>";
echo "<th>아이디</th>";
echo "<th>이름</th>";
echo "<th>닉네임</th>";
echo "<th>E-MAIL</th>";
echo "<th>전화번호</th>";
echo "<th>휴대폰번호</th>";
echo "<th>성별</th>";
echo "<th>생년월일</th>";
echo "<th>가입일</th>";
echo "<th>최종접속일</th>";
echo "<th>권한</th>";
echo "</tr>";

for ($i=0; $row=sql_fetch_array($result); $i++) {
    // 데이터 가공
    $mb_gender = '';
    if ($row['mb_gender'] == 'M') {
        $mb_gender = '남성';
    } else if ($row['mb_gender'] == 'F') {
        $mb_gender = '여성';
    }

    // 테이블 출력을 위한 HTML 코드 추가
    echo "<tr>";
    echo "<td>" . ($i+1) . "</td>";
    echo "<td>" . $row['mb_id'] . "</td>";
    echo "<td>" . $row['mb_name'] . "</td>";
    echo "<td>" . $row['mb_nick'] . "</td>";
    echo "<td>" . $row['mb_email'] . "</td>";
    echo "<td>" . $row['mb_tel'] . "</td>";
    echo "<td>" . $row['mb_hp'] . "</td>";
    echo "<td>" . $mb_gender . "</td>";
    echo "<td>" . $row['mb_birth'] . "</td>";
    echo "<td>" . $row['mb_datetime'] . "</td>";
    echo "<td>" . $row['mb_today_login'] . "</td>";
    echo "<td>" . $row['mb_level'] . "</td>";
    echo "</tr>";
}

// 테이블 출력을 위한 HTML 코드 추가
echo "</table>";

// 엑셀 다운로드
 array_to_excel($data, '회원리스트');
?>
 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 12개

2년 전
@디지털홍익인간
[http://sir.kr/data/editor/2307/50aad91a6bc80d138f69d0a81644a2db_1689510639_3309.jpeg]
2년 전
@디지털홍익인간 v5.5.8.3입니다. PHP Version 7.0.33이구요.

게시글 목록

번호 제목
22349
22347
22312
22308
22303
22282
22269
22259
22253
22234
22221
22197
22191
22179
22151
22144
22135
22130
22118
22110
22098
22095
22076
22057
22053
22051
22050
22046
22044
22042