• php 导出数据的处理


    今天改一个微赞上的项目  导出人员列表   顺便会议一下当初的思路  

    代码如下

    点击导出按钮 在site.php执行如下代码

    public function dowebdown(){
    header("Content-type:application/vnd.ms-excel");
    header("Content-Disposition:filename=test.xls");
    $sql = "SELECT * FROM ".tablename('weixin_luckuser');
    $list = pdo_fetchall($sql);
    //var_dump($list);
    echo "<h1 align='center'>中奖名单</h1>";
    echo "<table align='center' border=1 width='1300px' height='50px' cellpading=0 cellspacing=0>";
    echo "<tr><td>微信昵称</td><td>真实姓名</td><td>奖项</td><td>奖品名称</td><td>中奖时间</td><td>领奖SN码</td><td>用户电话</td><td>用户部门</td></tr>";
    foreach ($list as &$row){
    $info = pdo_fetch("SELECT nickname,mobile,bumen,realname FROM ".tablename('weixin_flag')."WHERE openid = :openid ",array(':openid'=>$row['openid']));
    //print_r($info);die;
    $luckinfo = pdo_fetch("SELECT tag_name,luck_name FROM ".tablename('weixin_awardlist')." WHERE id = {$row['awardid']}");
    $row['tag_name'] = $luckinfo['tag_name'];
    $row['luck_name'] = $luckinfo['luck_name'];
    $row['nickname'] = $info['nickname'];
    $row['realname'] = $info['realname'];
    $row['mobile'] = $info['mobile'];
    $row['bumen'] = $info['bumen'];
    echo "<tr>";
    echo "<td>";
    echo "{$row['nickname']}";
    echo "</td>";
    echo "<td>";
    echo "{$row['realname']}";
    echo "</td>";
    echo "<td>";
    echo "{$row['awardid']}";
    echo "</td>";
    echo "<td>";
    echo "{$row['luck_name']}";
    echo "</td>";
    echo "<td>";
    echo date("Y-m-d h:i:s","{$row['createtime']}");
    echo "</td>";
    echo "<td>";
    echo "{$row['createtime']}";
    echo "</td>";
    echo "<td>";
    echo "{$row['mobile']}";
    echo "</td>";
    echo "<td>";
    echo "{$row['bumen']}";
    echo "</td>";
    echo "</tr>";
    }
    echo "</table>";
    }

    主要是头部的两行代码  :  这样就把一个数据导出来了  是不是很简单

  • 相关阅读:
    IOS使用 swizzle 解决一些错误
    Objective-C的hook方案(一): Method Swizzling
    jmeter录制Chrome浏览器https请求进行压力测试
    FIDDLER导出JMX文件,JMETER打开导出的JMX报错的解决方式
    Fiddler的PC端与手机端抓包配置步骤
    初识中间件之消息队列--提高服务性能
    Python虚拟环境配置应用
    jmeter三种阶梯式加压
    JMETER-正则表达式提取与查看变量是否提取正确
    jmeter的线程数,并发用户数,TPS,RPS 关系解说
  • 原文地址:https://www.cnblogs.com/qjyking/p/5234492.html
Copyright © 2020-2023  润新知