묻고답하기
특정 게시판 리스트를 엑셀파일로 출력
2012.01.27 20:12
댓글 2
-
송동우
2012.01.27 20:59
-
클라우
2012.01.27 21:20
항상 감사합니다.ㅠㅠ -
클라우
2012.01.27 21:22
앗! 그 게시판의 모든 걸 가져오네요.(title_bold title_color content readed_count voted_count blamed_count comment_count trackback_count uploaded_count 이런 것은 안 가져오고 실제 게시판을 클릭했을 때 목록 list 보여지고 있는 항목을 가져오고 싶은데 이건 어렵나요?) -
송동우
2012.01.27 22:34
<?php
$info = array(
"host" => "호스트",
"user" => "아이디",
"pass" => "비번",
"db" => "DB명",
"table" => "xe_documents",
"module_srl" => 게시판모듈번호
);
$getFields = array("title","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> -
유유히
2013.01.24 16:29
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /web/home/charmnet/html/modules/beluxe/cs.php on line 40 -
유유히
2013.01.24 16:29
다운까지는 되는 되요 이런 에로가 뜨네요 뭇은 뜻인지 ?
<?php
$info = array(
"host" => "호스트",
"user" => "아이디",
"pass" => "비번",
"db" => "DB명",
"table" => "xe_documents",
"module_srl" => 특정게시판 모듈번호
);
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($field[$i]=="extra_vars")
{
$field[$i] = "tel";
echo "<th>".$field[$i]."</th>";
$field[$i] = "extra_vars";
}
else 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>";
for( $i=0 ; $i<count($field) ; $i++ )
{
echo "<td>".htmlspecialchars($data["$field[$i]"])."</td>";
}
echo"</tr>";
}
?>
</table>
</body>
</html>