묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
특정 게시판 리스트를 엑셀파일로 출력 확장변수 까지 같이 출력 할려고 하는데...
2013.02.13 11:40
특정 게시판 리스트를 엑셀파일로 출력 확장변수 까지 같이 출력 할려고 하는데
아래처럼 하면 확장변수가 옆으로 안가고 아래로 가요 도와 주세요 -.-
<?php
$info = array(
"host" => "호스트",
"user" => "아이디",
"pass" => "비번",
"db" => "DB명",
"table" => "xe_documents",
"table1" => "xe_document_extra_vars",
"module_srl" => "1086",
);
$getFields = array("title","nick_name","regdate","ipaddress","user_id",); //출력원하는 칼럼을 배열로 입력
$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">
<style type="text/css">
.a {
color: #FD4E02;
font-weight: bold;
}
</style>
</head>
<body>
<table width="800" height="215" border="0" cellpadding="0" cellspacing="0"><tr>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle" class="a">12</td></tr></table>
<table border=1>
<tr align=center>
<?php
$fields = mysql_list_fields("$info[db]", "$info[table]");
$columns = mysql_num_fields($fields);
for( $i=0 ; $i<$columns ; $i++ )
{
$field[$i]=mysql_field_name($fields, $i);
if( in_array($field[$i], $getFields) ) echo "<th>".$field[$i]."</th>";
}
?>
</tr>
<?php
$result = mysql_query("select * from $info[table] where module_srl = $info[module_srl]");
while( $data = mysql_fetch_assoc($result) )
{
echo"<tr>";
foreach( $data as $key => $val )
{
if( in_array($key, $getFields) ) echo "<th>".htmlspecialchars($val)."</th>";
}
echo"</tr>";
}
?>
</table>
<td>
</td>
<td>
<table border=1>
<tr align=center>
<?php
$fields = mysql_list_fields("$info[db]", "$info[table1]");
$columns = mysql_num_fields($fields);
for( $i=0 ; $i<$columns ; $i++ )
{
$field[$i]=mysql_field_name($fields, $i);
if( in_array($field[$i], $getFields1) ) echo "<th>".$field[$i]."</th>";
}
?>
<?php
$result = mysql_query("select * from $info[table1] where module_srl = $info[module_srl]");
while( $data = mysql_fetch_assoc($result) )
{
echo"<tr>";
foreach( $data as $key => $val )
{
if( in_array($key, $getFields1) ) echo "<th>".htmlspecialchars($val)."</th>";
}
echo"</tr>";
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>