묻고답하기
회원정보 확장변수..추출하는방법..ㅠㅠ
2015.05.26 16:19
-
<?php
$info = array(
"host" => "",
"user" => "",
"pass" => "",
"db" => ",
"table" => ""
);
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=member.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]");
while( $data = mysql_fetch_assoc($result) )
{
echo"<tr>";
for( $i=0 ; $i<count($field) ; $i++ )
{
if( $field[$i] == "extra_vars" )
{
$temp = unserialize($data["$field[$i]"])->hp;
$temp = explode("|@|", $temp);
echo "<td>".$temp[0]."-".$temp[1]."-".$temp[2]."</td>";
}
else echo "<td>".$data["$field[$i]"]."</td>";
}
echo"</tr>";
}
?>
</table>
</body>
</html>
다른건 다 잘나오는데..확장변수에 hp로연락처도 저렇게 빼면 된다는데 안되네요 ㅠㅠ
혹시 뭐 잘못된 부분이 있을까요?