不知道mysql自带的命令可以导出文本,更不知道可以导出你要的那种格式的。
解决方案 »
- JS 弹出窗口被浏览器阻截问题
- 字符串转数组的问题,求助
- 我红帽子 linux 时默认装了 httpd 服务,我想卸载它,重新装apahce和php,在线等。
- 将网址所在的页面,用“网页,仅html的形式”保存在本地硬盘上,有什么方法?
- 如果把多个表的记录查询出来????
- 无人看守自动打印
- 发现一个图书下载的地址,里面有好多计算机图书,共享....
- 传值传不过来,怎么办??
- php的问题?急急急????
- apache+php正常,mysql安装正常,服务也启动了,但是php调用不行,密码都没错
- [ 超级郁闷 ] smarty方便了程序设计人,却给界面设计者带来了更多的烦恼?
- 关于PHP5 中 MySQLi 的问题.
<?php
$mylink=mysql_connect("IP","登录名","密码");
mysql_select_db("数据库名",$mylink);Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Content-type:application/vnd.ms-excel");
Header("Content-Disposition:attachment;filename=export_excel_zsc.xls");
echo $province.'省';
if($province=='全部'){
$pro=" and 1=1 ";
}
else{
$pro=" and prov='".$province."'";
}
//存储显示的个数
$coun=10;
$date_ls=$_POST['year_from']."-".$_POST['month_from']."-".$_POST['date_from'];
$date_from=$_POST['year_from']."-".$_POST['month_from']."-".$_POST['date_from'].' 00:00:00';
$date_to=$_POST['year_from']."-".$_POST['month_from']."-".$_POST['date_from'].' 23:59:59';
$ywh=$_POST['ywh'];
if($ywh=='全部'){
$ywh_tj=" 1=1 ";
$ls='所有';
}
else{
$ywh_tj=" SpNum='".$ywh."'";
$ls=$ywh;
}
$tx=$date_ls.'('.$ls.')业务总时长统计';
echo $tx."\n\n";//-------------输出业务名
$sql_output="select sum(CountTime) as a,SpNum from IVR_TrffForm where 1=1 and StartTime>='".$date_from."' and StartTime<='".$date_to."' and ".$ywh_tj." and SpNum<>''".$pro." group by SpNum order by a desc";
$result_output=mysql_query($sql_output,$mylink);
if(mysql_num_rows($result_output)>0){
$q=0;
echo "业务号:"."\t";
while($array_yh=mysql_fetch_array($result_output)){
$ch_sec=round($array_yh['a']/60,2);
echo $array_yh['SpNum']."业务"."\t"; }
echo "\n";
$sql_output="select sum(CountTime) as a,SpNum from IVR_TrffForm where 1=1 and StartTime>='".$date_from."' and StartTime<='".$date_to."' and ".$ywh_tj." and SpNum<>''".$pro." group by SpNum order by a desc";
$result_output=mysql_query($sql_output,$mylink);
if(mysql_num_rows($result_output)>0){
$q=0;
echo "分钟:"."\t";
while($array_yh=mysql_fetch_array($result_output)){
$ch_sec=round($array_yh['a']/60,2);
//$array_ls[$q][]=$ch_sec;
//$array_pro[$q]=$array_yh['SpNum']."(".$ch_sec."分钟)";
$q=$q+1;
echo round($array_yh['a']/60,2)."\t"; }
}
}
else{
echo "没有符合的记录!";
}
?>
首先感谢你的帮助。
你的程序大至上能读懂,关键是
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Content-type:application/vnd.ms-excel");
Header("Content-Disposition:attachment;filename=export_excel_zsc.xls");
这4句不太明白,能否详细解释下。不胜感激!
但现在问题还没有解决,是我太菜了 :(
那位给出较具体的代码,或较明朗的思路,或相似的程序!