묻고답하기
게시판 리스트를 엑셀로 불러오고 싶습니다.
2013.04.16 14:58
게시판에 있는 내용과 확장변수에 있는 것들을 같이 불러오고 싶은데
확장변수가 옆으로 안가고 밑으로 가네요;;;; 어떻게방법이 없을까요 ㅠㅠ
소스는 이렇습니다.
<?php
$info = array(
"host" => "localhost",
"user" => "root",
"pass" => "apmsetup",
"db" => "dd",
"table" => "xe_documents",
"table1" => "xe_document_extra_vars",
"module_srl" => "1088",
);
$getFields = array("title","nick_name","regdate","value");
$getFields1 = array("value");//출력원하는 칼럼을 배열로 입력
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=documents.xls");
$con = mysql_connect($info[host], $info[user], $info[pass]) || die(mysql_error());
mysql_query("set names utf8");
$con_db = mysql_select_db($info[db]) || die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=Content-Type content=text/html; charset="utf-8">
</head>
<body>
<table border=1>
<tr align=center>
<?php
$fields = mysql_list_fields("$info[db]", "$info[table]");
$fields1 = mysql_list_fields("$info[db]", "$info[table1]");
$columns = mysql_num_fields($fields);
$columns1 = mysql_num_fields($fields1);
for( $i=0 ; $i<$columns ; $i++ )
{
$field[$i]=mysql_field_name($fields, $i);
if( in_array($field[$i], $getFields) ) echo "<th>".$field[$i]."</th>";
}
for ( $i=0; $i<$columns1; $i++) {
$field1[$i]=mysql_field_name($fields1, $i);
/*echo "<th>".$field[$i]. "</th>";*/
}
?>
<tr>
<td>제목</td>
<td>이름</td>
<td>등록일</td>
<td>아파트명</td>
<td>장비TID</td>
<td>장애담당</td>
<td>담당자연락처</td>
<td>장비점검 요청일시</td>
<td>장애접수 건수</td>
<td>장애내역</td>
<td>비고</td>
<td>점검자(운용)</td>
<td>점검일시(운용)</td>
<td>점검자연락처(운용)</td>
<td>비고</td>
<td>점검결과(운용)</td>
<td>완료여부</td>
<td>분류</td>
</tr>
<?php
$result = mysql_query("select * from $info[table] as A, $info[table1] as B where A.module_srl=B.module_srl and A.document_srl=B.document_srl and A.module_srl='1088' and B.var_idx order by A.document_srl, regdate desc");
$ctmp = 1;
echo"<tr>";
while( $data = mysql_fetch_assoc($result) )
{
foreach( $data as $key => $val )
{
if( in_array($key, $getFields) ) echo "<td>".htmlspecialchars($val)."</td>";
}
echo "</tr>";
}
?>
</table>
</body>
</html>