//exp.php 用于导出
include_once 'conn.php';
$savename = date("YmjHis");
mysql_query("Set Names 'gbk'");
$file_type = "vnd.ms-excel";
$file_ending = "xls";
header("Content-Type: application/$file_type;charset=big5");
header("Content-Disposition: p_w_upload; filename=".$savename.".$file_ending");
header("Pragma: no-cache");
$sql = "Select * from zhbyz_2011 WHERE riq>='$_GET[ac]' and riq<='$_GET[bc]' ORDER BY `id` DESC";
$result=mysql_query($sql);
#print_r($sql);
echo("$title\n");
$sep = "\t";
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo mysql_field_name($result,$i) . "\t";
}
print("\n");
$i = 0;
while($row = mysql_fetch_row($result)) {
$schema_insert = "";
for($j=0; $j
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
$i++;
}
return (true);
?>