채택완료

엑셀로 출력을 하고 싶은데...

Copy
<?

ob_start();

include_once($_SERVER['DOCUMENT_ROOT'] ."/common.php");

 


header("Content-type:application/vnd.ms-excel");

header("Content-Disposition:attachment;filename=view.xls");

 


$is_title="엑셀 문서 다운로드";

 


$sql="select * from g5_member";

$is_print=sql_fetch($sql);

?>

<!doctype html>

<html lang="ko">

<head>

<meta charset="UTF-8">

<style type="text/css">

.txt {mso-number-format:'\@'}

</style>

<title>수련회등록현황</title>

</head>

<body>

<table>

<tr>

<th scope="col">번호</th>

<th scope="col">이름</th>

<th scope="col">연락처</th>

<th scope="col">지구</th>

<th scope="col">학교</th>

<th scope="col">학번</th>

<th scope="col">선택특강</th>

<th scope="col">등록현황</th>

</tr>
 <?php
        for ($i=0; $i<count($is_print); $i++) {
         ?>
<tr>

<td class='txt'><?=$is_print[$i]['mb_id']?></td>

<td class='txt'><?=$is_print[$i]['mb_name']?></td>

<td class='txt'><?=$is_print[$i]['mb_hp']?></td>

<td class='txt'><?=$is_print[$i]['mb_5']?></td>

<td class='txt'><?=$is_print[$i]['mb_3']?></td>

<td class='txt'><?=$is_print[$i]['mb_4']?></td>

<td class='txt'><?=$is_print[$i]['mb_2']?> / <?=$is_print[$i]['mb_10']?></td>

<td class='txt'><?=$is_print[$i]['mb_1']?></td>

</tr>
<?}?>
</table>

</body>

</html>

이렇게 해서 원하는 내용만 따로 엑셀로 뽑을려고 하거든요.

그런데...

 <?php        for ($i=0; $i<count($is_print); $i++) {         ?>....<?}?>

이걸 넣어야 리스트들이 주루룩 나오는걸로 알고 있습니다.

그런데... 위 문을 넣으면 아예정보가 나오질 않습니다.

넣지 않을때는 정보 하나는 엑셀로 나왔거든요...

뭐가 문제인지 알 수 있을까요? 해결방법이 궁금해요 ㅜㅜ

|

답변 1개 / 댓글 2개

채택된 답변
+20 포인트

$sql="select * from g5_member";
$is_print=sql_fetch($sql);

위를

$sql="select * from g5_member";
$result=sql_query($sql);

로 수정하고

for ($i=0; $list = sql_fetch_array($result); $i++) {

하면 됩니다.

답변에 대한 댓글 2개

값 출력 시에는 <?=$list['필드']'?> 하면 됩니다.
단번에 해결되었네요~~
잘 배웠습니다.^^

답변을 작성하려면 로그인이 필요합니다.