标签:excel
<?php
/**
* Created by PhpStorm.
* User: chenxiaolong
* Date: 2016/8/16
* Time: 14:37
*/
header("Content-type:application/vnd.ms-excel;charset=utf-8");
header("Content-Disposition:attachment;filename=Export_top_100.xls");
$tab="\t"; $br="\n";
$head= ‘rank‘ . $tab . "skinid". $tab . ‘title‘ .$tab . ‘num‘ . $tab . ‘skinurl‘ . $br;
echo $head;
$db = array (
‘database‘ => ‘360se_skin‘, // 库名称
‘host‘ => ‘220.181.158.172‘, // 数据库地址
‘port‘ => 3306, // 端口
‘login‘ => ‘360se_skin‘, // 用户名
‘password‘ => ‘360se_skin@browser‘, // 密码
‘persistent‘ => false, // 是否使用长链接
‘charset‘ => ‘utf8‘,
);
$mysqli = new mysqli($db[‘host‘],$db[‘login‘],$db[‘password‘],$db[‘database‘],$db[‘port‘]);
$mysqli->query("set names utf8");
$sql = "select * from skins where deleted=0 order by num desc limit 101";
$query = $mysqli->query($sql);
$i = 1;
while($res=$query->fetch_assoc()) {
echo $i . $tab;
echo $res[‘skinid‘] . $tab;
echo $res[‘skinname‘] . $tab;
echo $res[‘num‘] . $tab;
echo $res[‘skinurl‘];
echo $br;
$i++;
}
标签:excel
原文地址:http://chenxiaolong.blog.51cto.com/8786841/1839292