日期:2014-05-16 浏览次数:20431 次
http://192.168.0.200/test/khall.php?mindate=2014-04-01&maxdate=2014-04-30&keys=
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachement;filename=".$_GET['keys']."".date("Ymd").".xls");
echo iconv('utf-8', 'gbk', "时间\t类型\t区域\t姓名\t具体地址\t联系电话\t证件号\t套餐\t时长\t赠送\t金额\t经办人\t帐号\t备注\n");
include("db.php");
date_default_timezone_set("PRC");
$mindate=$_GET['mindate'];
$maxdate=$_GET['maxdate'];
$dates="dates>='".$mindate."' and dates<='".$maxdate."'";
if (!empty($_GET['keys'])) {
$keys=$_GET['keys'];
$ww="(`area` like '%".$keys."%' or `type` like '%".$keys."%' or `names` like '%".$keys."%' or `add` like '%".$keys."%' or `dur` like '%".$keys."%')";
$wh="where {$ww} and {$dates}"; }
else{$wh="where {$dates}";}
$sql="SELECT * FROM `khxx` {$wh}";
// echo "$sql";
mysql_query('set names gbk');
$query=mysql_query($sql);
$rs=mysql_fetch_array($query);
while ($rs=mysql_fetch_array($query)){
echo "{$rs['dates']}\t{$rs['type']}\t{$rs['area']}\t{$rs['names']}\t{$rs['add']}\t{$rs['phone']}\t{$rs['no']}\t{$rs['set']}\t{$rs['dur']}\t{$rs['give']}\t{$rs['moneys']}\t{$rs['attn']}\t{$rs['username']}\t{$rs['rem']}\n";
}
?>
SELECT * FROM `khxx` where dates>='2014-04-01' and dates<='2014-04-30'