묻고답하기
게시판을 엑셀로 불러올때에 질문있어요
2013.04.17 14:19
밑에 처럼 작성을 해서 엑셀로 불러오면 regdate부분이 2.01304E+13 이렇게 나오는 데 고칠 방법이 없을까요?
소스어디다가 어떤 명령어를 넣어야하나요?ㅠㅠ
<?php
$info = array(
"host" => "",
"user" => "",
"pass" => "",
"db" => "",
"table" => "xe_documents",
"module_srl" =>
);
$getFields = array("title","content","nick_name","regdate"); //출력원하는 칼럼을 배열로 입력
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]");
$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 "<td>".htmlspecialchars($val)."</td>";
}
echo"</tr>";
}
?>
</table>
</body>
</html>
http://www.xpressengine.com/qna/21869977