PHP微擎简易导表程序
<?php
global $_GPC, $_W;
$aid = $_GPC["aid"];
$lottery = pdo_get("me_daticj_lottery", array("uniacid" => $_W["uniacid"], "id" => $aid));
$condition = " a.uniacid = '{$_W["uniacid"]}' AND a.aid = {$aid} AND a.userid = b.id AND a.awardid = c.id";
if (!empty($_GPC["nickname"])) {
$condition .= " AND b.nickname LIKE '%{$_GPC["nickname"]}%'";
}
if (!empty($_GPC["realname"])) {
$condition .= " AND b.realname LIKE '%{$_GPC["realname"]}%'";
}
if (!empty($_GPC["mobile"])) {
$condition .= " AND b.mobile LIKE '%{$_GPC["mobile"]}%'";
}
$condition .= " AND a.hasAward=1 ORDER BY a.id DESC";
$list = pdo_fetchall("SELECT b.nickname,b.realname,b.mobile,c.award_type,c.award_name,a.status,a.createtime,b.xiaoqu,b.isvip FROM " . tablename("me_daticj_winner") . " a, " . tablename("me_daticj_user") . " b, " . tablename("me_daticj_awards") . " c WHERE {$condition}");
$html = "\xef\xbb\xbf";
$html .= "微信昵称\t,真实姓名\t,手机号码\t,奖品类型\t,奖品名称\t,发奖状态(1已发0未发)\t,中奖时间\t,校区\t,是否是会员(1是会员0不是会员)\t,\n";
foreach ($list as $key => $value) {
foreach ($value as $k => $v) {
$row = $v . "\t,";
$html .= $row;
}
$html .= "\n";
}
$filename = "中奖记录----" . $lottery["title"];
header("Content-type:text/csv");
header("Content-Disposition:attachment; filename=" . $filename . ".csv");
echo $html;
exit;
直接访问该路由即可
评论 (0)