<?php
header("Content-type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename = excel_download.xls");
print("<meta http-equiv=\"Content-Type\" content=\"application/vnd.ms-excel; charset=utf-8\">");
$excel = "<table border='1'>
<tr>
<td>이름</td>
<td>부서</td>
<td>나이</td>
<td>성별</td>
</tr>
";
$qry = "SELECT * FROM users";
$res = $mysqli->query($qry);
// DB 에 저장된 데이터 출력
foreach ($res->fetch_object() as $row) {
$excel .= "
<tr>
<td>" . $row->name . "</td>
<td>" . $row->dept . "</td>
<td>" . $row->age . "</td>
<td>" . $row->gender . "</td>
</tr>
";
}
$excel .= "</table>";
echo $excel;
?>
'Back-end > php, Laravel' 카테고리의 다른 글
valet 환경 세팅 (mysql 설치) (0) | 2023.01.08 |
---|---|
(php) Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) 오류 해결 방법 (0) | 2022.09.17 |
Homestead 에서 php 8.x 버전 사용하기 (0) | 2022.08.09 |
(PHP) 정규식 정리 (0) | 2021.08.05 |
(phpstorm) 무한 Updating Index 현상 해결 법 (0) | 2021.08.01 |