谁有实际的代码~!
导入只要求一个
<form ENCTYPE="multipart/form-data" ACTION="<?php echo"".$PHP_SELF.""; ?>" METHOD="POST">
<p>导入CVS数据 <input NAME="MyFile" TYPE="file"> <input VALUE="提交" TYPE="submit">
</p>
</form> 导出需要先显示此张表~!在点下按钮就有到处的功能??大家以前做过吗??SOS
导入只要求一个
<form ENCTYPE="multipart/form-data" ACTION="<?php echo"".$PHP_SELF.""; ?>" METHOD="POST">
<p>导入CVS数据 <input NAME="MyFile" TYPE="file"> <input VALUE="提交" TYPE="submit">
</p>
</form> 导出需要先显示此张表~!在点下按钮就有到处的功能??大家以前做过吗??SOS
$filename = time().".csv";
header("Content-disposition: filename=$filename");
header("Content-type: unknown/unknown");
echo "字段,字段,字段,字段,字段,字段";
while ($row=@mysql_fetch_array($ressult))
{
echo base64_decode("DQo=")."\"$row[0]\",\"$row[1]\",\"$row[2]\",\"$row[3]\",\"$row[4]\",\"$row[5]\"";
/*上式中“base64_decode(\"DQo=\")”是换行符,之所以不用“\n”,是因为两者不完全相同。*/
}
die;
}
//导出XLS
if($type=="xls"){
$filename = time().".xls";
header("Content-disposition: filename=$filename");
header("Content-type: unknown/unknown");
echo "字段"."\t";
echo "字段"."\t";
echo "字段"."\t";
echo "字段"."\t";
echo "字段"."\t";
echo "字段"."\n";
while ($row = @mysql_fetch_array($ressult))
{
echo $row[0]."\t";
echo $row[1]."\t";
echo $row[2]."\t";
echo $row[3]."\t";
echo $row[4]."\t";
echo $row[5]."\n";
}
die;
}
header("Content-Type: application/vnd.ms-excel");
header("Pragma: no-cache");
header("Expires: 0");
连接数据库
$sql = "select * from test";
$result = mysql_query($sql);
echo "字段名0"."\t";
echo "字段名1"."\t";
echo "字段名2"."\t";
echo "字段名3"."\t";
echo "字段名4"."\t";
echo "字段名5"."\n";
while ($row = mysql_fetch_array($ressult))
{
echo $row[字段0]."\t";
echo $row[字段1]."\t";
echo $row[字段2]."\t";
echo $row[字段3]."\t";
echo $row[字段4]."\t";
echo $row[字段5]."\n";
}
这是不是要求客户端也支持?