如果想搬把ecshop中的一些数据给导成xls格式,可以使用以下这段代码,非常好用。
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
/*
$ip ="localhost";
$db = "uc";
$user = "root";
$pwd = "root";
*/
$ip ="localhost";
$db = "shopuc";
$user = "shopuc";
$pwd = "##RFV##uc";
$con = mysql_connect($ip,$user,$pwd);
mysql_query("set names 'GBK'");
mysql_select_db($db);
$re = mysql_query("select * from uc_members order by uid desc");
$str = '';
while ($r = mysql_fetch_array($re)) {
echo iconv("UTF-8","GBK",$r['username'])."\t";
echo iconv("UTF-8","GBK",$r['email'])."\t\n";
}
?>
<?php
www.china1store.cn ;SZ:JO.LHU]\
$ip ="localhost";
$db = "shopuc";
$user = "shopuc";
$pwd = "##RFV##uc";
$con = mysql_connect($ip,$user,$pwd);
mysql_query('set names "utf8"');
mysql_select_db($db);
$re = mysql_query("select * from uc_members order by uid desc");
mysql_query("set names 'UTF8'");
$fp = fopen('file.csv', 'w');
while ($v = mysql_fetch_array($re)) {
fputcsv($fp, array(iconv("UTF-8","GBK",$v['username']),$v['email']));
} 独立网店制作
fclose($fp);
?>
<A href="/file.csv">x</a> www.china1store.net N9nx0k MRG]+iR0