<?php
if(!empty($_GET["key"]))
{
	if($_GET['title']==1)
		$scl=" and title like '%$_GET[key]%' ";
	elseif($_GET['title']==2)
		$scl=" and con like '%$_GET[key]%' ";
	elseif($_GET['title']==3)
		$scl=" and keyword='$_GET[key]' ";
	else
		$scl=" AND company like '%$_GET[key]%' ";
}
if(isset($_GET["statu"])&&$_GET["statu"]<4)
	$scl.=" AND statu=".intval($_GET['statu']);
if(!empty($_GET['type']))
	$scl.=" and type='$_GET[type]' ";
if($_SESSION["province"])
	$scl.=" and province='$_SESSION[province]'";
if($_SESSION["city"])
	$scl.=" and city='$_SESSION[city]'";
	
if($_GET['order']==1)
	$scl.=" order by uptime desc";
elseif($_GET['order']==2)
	$scl.=" order by ifpay desc";
elseif($_GET['order']==3)
	$scl.=" order by rank desc";
else
	$scl.=" order by id desc";

$sql="select title,company,uptime,con,pp from ".INFO." where 1 $scl ";
$db->query($sql);
$re=$db->getRows();
//-----------------------------------------------------------------------------------------------
$str=geticonv("所属公司\t产品名称\t所属品牌\t产品摘要\t发布时间\t\n"); 
foreach($re as $v)
{    
	$str .= geticonv("$v[company]\t$v[title]\t$v[pp]\t$v[con]\t$v[uptime]\t\n");
} 
$filename = date('Ymd').'.xls'; 
exportExcel($filename,$str); 
//===================================================================
function exportExcel($filename,$content)
{ 
	header("Content-type:text/csv"); 
	header("Content-Disposition:attachment;filename=".$filename); 
	header('Cache-Control:must-revalidate,post-check=0,pre-check=0'); 
	header('Expires:0'); 
	header('Pragma:public'); 
	echo $content;    
} 
function geticonv($str)
{
	return  iconv('utf-8','gb2312',$str); 
}
?>