19
2013-12

discuz6.1论坛活动php数据调用代码

做过的一个活动,自己写了代码,现在需要调用数据,把循环嵌套好好地用了,就写在这里了,以备不时之需。

<?php
//调用核心文件
require "function_webench.php";
require "../include/common.inc.php";
header('content-type:text/html; charset=gbk;');
if($act=='list') {
    $query=$db->query("select bbsid,count(bbsid) as nn,count(distinct time) as num from `cdb_webench20131115` group by bbsid order by num desc");
    echo '<p>每个人上传了多少作品</p><TABLE cellpadding="0" cellspacing="0" border="1"><TR><TD width=100 align=right>bbsid</TD><TD width=50 align=right>num</TD><TD width=50 align=right>重复</TD></TR>';
    while($res=$db->fetch_array($query)) {
        if($res['num']>=20) {
        echo '<TR><TD align=right>'.$res['bbsid'].'</TD><TD align=right>'.$res['num'].'</TD><TD align=right>'.$res['nn'].'</TD></TR>';
        $number++;
                }
    }
    echo '</TABLE>';
    echo $number;
}
      
if($act=='allinfo') {
    $query=$db->query("select bbsid,TIid,time,count(distinct time) as num from `cdb_webench20131115` where `time`>='2013-11-18' and `time`<='2013-11-30' group by bbsid order by num desc");
    echo '<TABLE cellpadding="0" cellspacing="0" border="1"><TR><TD width=100 align=right>用户名</TD><TD width=100 align=right>TI官网邮箱</TD><TD width=100 align=right>姓名</TD><TD width=100 align=right>手机</TD><TD width=100 align=right>单位</TD><TD width=100 align=right>地址</TD><TD width=100 align=right>职位类别</TD><TD width=100 align=right>单位行业</TD></TR>';
    while($res=$db->fetch_array($query)) {
        $bbsid[]=$res;
    }
foreach ($bbsid as $key=>$var){
    $bb=$bbsid[$key]['bbsid'];
    $query2=$db->query("SELECT mf.uid,m.username,mf.field_3,mf.field_4,mf.field_5,mf.field_13,mf.field_8,mf.field_11 FROM `cdb_memberfields` mf left join `cdb_members` m ON m.uid=mf.uid where m.username='{$bb}'");
    while($temp=$db->fetch_array($query2)){
        if($temp['field_8']=='001') {
            $temp['field_8']='研发工程师/测试工程师';
        }
        if($temp['field_8']=='003') {
            $temp['field_8']='研发主管/CTO/总经理';
        }
        if($temp['field_8']=='005') {
            $temp['field_8']='元器件采购/工程生产质量管理';
        }
        if($temp['field_8']=='007') {
            $temp['field_8']='技术支持/维修';
        }
        if($temp['field_8']=='009') {
            $temp['field_8']='咨询顾问/产品销售';
        }
        if($temp['field_8']=='0010') {
            $temp['field_8']='科研/学术/教育';
        }
        if($temp['field_8']=='0011') {
            $temp['field_8']='其他';
        }
      
        if($temp['field_11']=='001') {
            $temp['field_11']='网络通信';
        }
        if($temp['field_11']=='002') {
            $temp['field_11']='计算机';
        }
        if($temp['field_11']=='003') {
            $temp['field_11']='消费电子';
        }
        if($temp['field_11']=='004') {
            $temp['field_11']='工业控制/自动化';
        }
        if($temp['field_11']=='005') {
            $temp['field_11']='汽车电子';
        }
        if($temp['field_11']=='006') {
            $temp['field_11']='安防电子';
        }
        if($temp['field_11']=='007') {
            $temp['field_11']='医疗电子';
        }
        if($temp['field_11']=='008') {
            $temp['field_11']='航空航天及军用';
        }
        if($temp['field_11']=='009') {
            $temp['field_11']='电子元器件经销商';
        }
        if($temp['field_11']=='0010') {
            $temp['field_11']='半导体IC设计制造厂商';
        }
        if($temp['field_11']=='0011') {
            $temp['field_11']='测试测量';
        }
        if($temp['field_11']=='0012') {
            $temp['field_11']='其他';
        }
        echo '<TR><TD align=right>'.$bb.'</TD><TD align=right>'.$var['TIid'].'</TD><TD align=right>'.$temp['field_3'].'</TD><TD align=right>'.$temp['field_5'].'</TD><TD align=right>'.$temp['field_4'].'</TD><TD align=right>'.$temp['field_13'].'</TD><TD align=right>'.$temp['field_8'].'</TD><TD align=right>'.$temp['field_11'].'</TD></TR>';
        $number++;
    }
}
      
    echo '</TABLE>';
    echo $number++;
}
      
      
if($act=='all') {
    $query=$db->query("select bbsid,TIid,time,count(bbsid) as nn,count(distinct time) as num from `cdb_webench20131115` where `time`>='2013-11-18' and `time`<='2013-12-17' group by bbsid order by num desc");
    echo '<TABLE cellpadding="0" cellspacing="0" border="1"><TR><TD width=100 align=right>用户名</TD><TD width=100 align=right>TI官网邮箱</TD><TD width=100 align=right>姓名</TD><TD width=100 align=right>手机</TD><TD width=100 align=right>单位</TD><TD width=100 align=right>地址</TD><TD width=100 align=right>职位类别</TD><TD width=100 align=right>单位行业</TD><TD width=50 align=right>坚持天数</TD><TD width=50 align=right>有无重复上传</TD></TR>';
    while($res=$db->fetch_array($query)) {
        $bbsid[]=$res;
    }
foreach ($bbsid as $key=>$var){
    $bb=$bbsid[$key]['bbsid'];
    $query2=$db->query("SELECT mf.uid,m.username,mf.field_3,mf.field_4,mf.field_5,mf.field_13,mf.field_8,mf.field_11 FROM `cdb_memberfields` mf left join `cdb_members` m ON m.uid=mf.uid where m.username='{$bb}'");
    while($temp=$db->fetch_array($query2)){
        if($temp['field_8']=='001') {
            $temp['field_8']='研发工程师/测试工程师';
        }
        if($temp['field_8']=='003') {
            $temp['field_8']='研发主管/CTO/总经理';
        }
        if($temp['field_8']=='005') {
            $temp['field_8']='元器件采购/工程生产质量管理';
        }
        if($temp['field_8']=='007') {
            $temp['field_8']='技术支持/维修';
        }
        if($temp['field_8']=='009') {
            $temp['field_8']='咨询顾问/产品销售';
        }
        if($temp['field_8']=='0010') {
            $temp['field_8']='科研/学术/教育';
        }
        if($temp['field_8']=='0011') {
            $temp['field_8']='其他';
        }
      
        if($temp['field_11']=='001') {
            $temp['field_11']='网络通信';
        }
        if($temp['field_11']=='002') {
            $temp['field_11']='计算机';
        }
        if($temp['field_11']=='003') {
            $temp['field_11']='消费电子';
        }
        if($temp['field_11']=='004') {
            $temp['field_11']='工业控制/自动化';
        }
        if($temp['field_11']=='005') {
            $temp['field_11']='汽车电子';
        }
        if($temp['field_11']=='006') {
            $temp['field_11']='安防电子';
        }
        if($temp['field_11']=='007') {
            $temp['field_11']='医疗电子';
        }
        if($temp['field_11']=='008') {
            $temp['field_11']='航空航天及军用';
        }
        if($temp['field_11']=='009') {
            $temp['field_11']='电子元器件经销商';
        }
        if($temp['field_11']=='0010') {
            $temp['field_11']='半导体IC设计制造厂商';
        }
        if($temp['field_11']=='0011') {
            $temp['field_11']='测试测量';
        }
        if($temp['field_11']=='0012') {
            $temp['field_11']='其他';
        }
        echo '<TR><TD align=right>'.$bb.'</TD><TD align=right>'.$var['TIid'].'</TD><TD align=right>'.$temp['field_3'].'</TD><TD align=right>'.$temp['field_5'].'</TD><TD align=right>'.$temp['field_4'].'</TD><TD align=right>'.$temp['field_13'].'</TD><TD align=right>'.$temp['field_8'].'</TD><TD align=right>'.$temp['field_11'].'</TD><TD align=right>'.$var['num'].'</TD><TD align=right>'.$var['nn'].'</TD></TR>';
        $number++;
    }
      
    }
    echo '</TABLE>';
    echo $number;
}
      
      
      
      
      
if($act=='down') {
    $query=$db->query("select id,bbsid,TIid,time,name,url from `cdb_webench20131115` where `time`>='2013-11-18' and `time`<='2013-12-17' order by bbsid,id desc");
    echo '<TABLE cellpadding="0" cellspacing="0" border="1"><TR><TD width=100 align=right>ID</TD><TD width=100 align=right>用户名</TD><TD width=100 align=right>TI官网邮箱</TD><TD width=100 align=right>姓名</TD><TD width=100 align=right>手机</TD><TD width=100 align=right>单位</TD><TD width=100 align=right>地址</TD><TD width=100 align=right>职位类别</TD><TD width=100 align=right>单位行业</TD><TD width=100 align=right>上传量</TD><TD width=50 align=right>下载</TD></TR>';
    while($res=$db->fetch_array($query)) {
        $bbsid[]=$res;
    }
foreach ($bbsid as $key=>$var){
    $bb=$bbsid[$key]['bbsid'];
    $query2=$db->query("SELECT mf.uid,m.username,mf.field_3,mf.field_4,mf.field_5,mf.field_13,mf.field_8,mf.field_11 FROM `cdb_memberfields` mf left join `cdb_members` m ON m.uid=mf.uid where m.username='{$bb}'");
      
    $query3=$db->query("select bbsid,TIid,time,count(distinct time) as num from `cdb_webench20131115` where `time`>='2013-11-18' and `time`<='2013-12-17' and bbsid='{$bb}' group by bbsid order by num desc");
    while($temp=$db->fetch_array($query2)){
        if($temp['field_8']=='001') {
            $temp['field_8']='研发工程师/测试工程师';
        }
        if($temp['field_8']=='003') {
            $temp['field_8']='研发主管/CTO/总经理';
        }
        if($temp['field_8']=='005') {
            $temp['field_8']='元器件采购/工程生产质量管理';
        }
        if($temp['field_8']=='007') {
            $temp['field_8']='技术支持/维修';
        }
        if($temp['field_8']=='009') {
            $temp['field_8']='咨询顾问/产品销售';
        }
        if($temp['field_8']=='0010') {
            $temp['field_8']='科研/学术/教育';
        }
        if($temp['field_8']=='0011') {
            $temp['field_8']='其他';
        }
      
        if($temp['field_11']=='001') {
            $temp['field_11']='网络通信';
        }
        if($temp['field_11']=='002') {
            $temp['field_11']='计算机';
        }
        if($temp['field_11']=='003') {
            $temp['field_11']='消费电子';
        }
        if($temp['field_11']=='004') {
            $temp['field_11']='工业控制/自动化';
        }
        if($temp['field_11']=='005') {
            $temp['field_11']='汽车电子';
        }
        if($temp['field_11']=='006') {
            $temp['field_11']='安防电子';
        }
        if($temp['field_11']=='007') {
            $temp['field_11']='医疗电子';
        }
        if($temp['field_11']=='008') {
            $temp['field_11']='航空航天及军用';
        }
        if($temp['field_11']=='009') {
            $temp['field_11']='电子元器件经销商';
        }
        if($temp['field_11']=='0010') {
            $temp['field_11']='半导体IC设计制造厂商';
        }
        if($temp['field_11']=='0011') {
            $temp['field_11']='测试测量';
        }
        if($temp['field_11']=='0012') {
            $temp['field_11']='其他';
        }
      
        while($NO=$db->fetch_array($query3)){
        if($NO['num']>=30) {
        echo '<TR><TD align=right>'.$var['id'].'</TD><TD align=right>'.$bb.'</TD><TD align=right>'.$var['TIid'].'</TD><TD align=right>'.$temp['field_3'].'</TD><TD align=right>'.$temp['field_5'].'</TD><TD align=right>'.$temp['field_4'].'</TD><TD align=right>'.$temp['field_13'].'</TD><TD align=right>'.$temp['field_8'].'</TD><TD align=right>'.$temp['field_11'].'</TD><TD align=right>'.$NO['num'].'</TD><TD align=right><a href=http://bbs.eeworld.com.cn/webench/webench.php?act=down&id='.$var['id'].' target=_blank>下载</a></TD></TR>';
        $number++;
                }
        }
    }
      
    }
    echo '</TABLE>';
    echo $number;
}
?>

除非注明,文章均为史亚永原创,欢迎转载!转载请注明本文地址,谢谢。

本文地址:http://www.shiyayong.cn/post/241.html

评论列表:

发表评论:

(设置个性头像)

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

无觅相关文章插件,快速提升流量