| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1425 人关注过本帖, 1 人收藏
标题:关于这种结果的获取:
取消只看楼主 加入收藏
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
结帖率:88.89%
收藏(1)
 问题点数:0 回复次数:6 
关于这种结果的获取:
请教各位大虾,这么个问题,我该怎么能实现?
我想通过数据库查询获得一些结果,要以这样的方式来体现,我该怎么来做呢?
sql="SELECT de, Sum(abc) as  cdd FROM table WHERE de in (SELECT distinct ff FROM table)"
查询的结果:de1=a1  cdd=170   de2=a2  cdd=600   de3=a3  cdd=800
rs.recordcount=3 我该怎么写语句才能得到如下的结果:
<%
dim total(3,2)   
total(1,1)=170
total(2,1)=600
total(3,1)=800

total(1,2)="a1"
total(2,2)="a2"
total(3,2)="a3"

total_no=3
%>                 请各位大虾指教,谢谢!
搜索更多相关主题的帖子: 结果 获取 
2008-09-11 01:06
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
收藏
得分:0 
咋都没点动静啊?请各位高手指教啊!
2008-09-12 10:40
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
收藏
得分:0 
哇,高手就是高手,是这样的,请问该怎么将数据库的数据转换为数组呢?能否举例赐教,谢谢!
2008-09-12 22:39
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
收藏
得分:0 
老大,运行后只出现了这样的结果,是不是那儿还有问题?因为我对ASP没有系统的学过,还有些东西摸不清楚,希望能指点更详细些,非常感谢!
出来的结果是这样的:
total(3,1)
total(0,0)=a1   total(0,1)=170                  
total(1,0)=a2   total(1,1)=600
total(2,0)=a3   total(2,1)=800
total(3,0)=
total(3,1)=
目标:
total(1,1)=170  total(2,1)=600  total(3,1)=800
total(1,2)="a1"  total(2,2)="a2"  total(3,2)="a3"

请指教,谢谢!

[[it] 本帖最后由 boyfuture 于 2008-9-14 00:09 编辑 [/it]]
2008-09-13 23:07
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
收藏
得分:0 
请教老大,有没有关于asp从数据库里将数据转化为饼图或柱状图及折线图的代码,尤其是将数据库的数值转化为数组的过程?不胜感激,等着急用,谢谢啊!我的邮箱地址:boyfuture@
2008-09-14 09:20
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
收藏
得分:0 
请高手们指点:这是asp绘图的代码,怎么处理数组的赋值是我一直没有获取到,请多多指教!
以下是折线图的代码:
<%dim total(4,3)
total(1,0)="中国经营报"
total(2,0)="招聘网"
total(3,0)="51Job"
total(4,0)="新民晚报"


total(0,1)="#FF0000,1.5,1,2,公司1"'参数1线条的颜色,参数2线条的宽度,参数3线条的类型,参数4转折点的类型,参数5线条名称
total(1,1)=200
total(2,1)=1200
total(3,1)=900
total(4,1)=600


total(0,2)="#0000FF,1,2,3,公司2"
total(1,2)=400
total(2,2)=500
total(3,2)=1040
total(4,2)=1600


total(0,3)="#004D00,1,1,3,公司3"
total(1,3)=900
total(2,3)=890
total(3,3)=1240
total(4,3)=1300


%><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[if !mso]>
<style>
v\:*         { behavior: url(#default#VML) }
o\:*         { behavior: url(#default#VML) }
.shape       { behavior: url(#default#VML) }
</style>
<![endif]-->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style>
TD {    FONT-SIZE: 9pt}
</style></head>
<body topmargin=5 leftmargin=0 scroll=AUTO>
<%call table2(total,80,60,300,150,3)%>
</body>
</html>

<%
function table2(total,table_x,table_y,all_width,all_height,line_no)
'参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,折线条数)
'纯ASP代码生成图表函数2——折线图
'作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@ Email:passwordgm@
'本人非常愿意和ASP,VML,FLASH的爱好者在HTTP://topclouds.进行交流和探讨
'版本1.0 最后修改日期 2003-8-11
'非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。

line_color="#69f"
left_width=70
total_no=ubound(total,1)

temp1=0
for i=1 to total_no
    for j=1 to line_no
        if temp1<total(i,j) then temp1=total(i,j)
    next
next
temp1=int(temp1)
if temp1>9 then
    temp2=mid(cstr(temp1),2,1)
    if temp2>4 then
        temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+1)*10^(len(cstr(temp1))-1)
    else
        temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+0.5)*10^(len(cstr(temp1))-1)
    end if
else
    if temp1>4 then temp3=10 else temp3=5
end if
temp4=temp3
response.write "<v:rect id='_x0000_s1027' alt='' style='position:absolute;left:"&table_x+left_width&"px;top:"&table_y&"px;width:"&all_width&"px;height:"&all_height&"px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect>"
for i=0 to all_height-1 step all_height/5
    response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width+length&"px,"&table_y+all_height-length-i&"px' to='"&table_x+all_width+left_width&"px,"&table_y+all_height-length-i&"px' strokecolor='"&line_color&"'/>"
    response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+(left_width-15)&"px,"&table_y+i&"px' to='"&table_x+left_width&"px,"&table_y+i&"px'/>"
    response.write ""
    response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x&"px;top:"&table_y+i&"px;width:"&left_width&"px;height:18px;z-index:1'>"
    response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>"&temp4&"</td></tr></table></v:textbox></v:shape>"
    temp4=temp4-temp3/5
next
response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width&"px,"&table_y+all_height&"px' to='"&table_x+all_width+left_width&"px,"&table_y+all_height&"px'/>"
response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width&"px,"&table_y&"px' to='"&table_x+left_width&"px,"&table_y+all_height&"px'/>"

dim line_code
redim line_code(line_no,5)
for i=1 to line_no
    line_temp=split(total(0,i),",")
    line_code(i,1)=line_temp(0)
    line_code(i,2)=line_temp(1)
    line_code(i,3)=line_temp(2)
    line_code(i,4)=line_temp(3)
    line_code(i,5)=line_temp(4)
next
for j=1 to line_no
    for i=1 to total_no-1
            x1=table_x+left_width+all_width*(i-1)/total_no
            y1=table_y+(temp3-total(i,j))*(all_height/temp3)
            x2=table_x+left_width+all_width*i/total_no
            y2=table_y+(temp3-total(i+1,j))*(all_height/temp3)
            response.write "<v:line id=""_x0000_s1025"" alt="""" style='position:absolute;left:0;text-align:left;top:0;z-index:1' from="""&x1&"px,"&y1&"px"" to="""&x2&"px,"&y2&"px"" coordsize=""21600,21600"" strokecolor="""&line_code(j,1)&""" strokeweight="""&line_code(j,2)&""">"
        select case line_code(j,3)
        case 1
        case 2
            response.write "<v:stroke dashstyle='1 1'/>"
        case 3
            response.write "<v:stroke dashstyle='dash'/>"
        case 4
            response.write "<v:stroke dashstyle='dashDot'/>"
        case 5
            response.write "<v:stroke dashstyle='longDash'/>"
        case 6
            response.write "<v:stroke dashstyle='longDashDot'/>"
        case 7
            response.write "<v:stroke dashstyle='longDashDotDot'/>"
        case else
        end select
        response.write "</v:line>"&CHR(13)
        select case line_code(j,4)
        case 1
        case 2
            response.write "<v:rect id=""_x0000_s1027"" style='position:absolute;left:"&x1-2&"px;top:"&y1-2&"px;width:4px;height:4px; z-index:2' fillcolor="""&line_code(j,1)&""" strokecolor="""&line_code(j,1)&"""/>"&CHR(13)
        case 3
            response.write "<v:oval id=""_x0000_s1026"" style='position:absolute;left:"&x1-2&"px;top:"&y1-2&"px;width:4px;height:4px;z-index:1' fillcolor="""&line_code(j,1)&""" strokecolor="""&line_code(j,1)&"""/>"&CHR(13)
        end select
    next
        select case line_code(j,4)
        case 1
        case 2
            response.write "<v:rect id=""_x0000_s1027"" style='position:absolute;left:"&x2-2&"px;top:"&y2-2&"px;width:4px;height:4px; z-index:2' fillcolor="""&line_code(j,1)&""" strokecolor="""&line_code(j,1)&"""/>"&CHR(13)
        case 3
            response.write "<v:oval id=""_x0000_s1026"" style='position:absolute;left:"&x2-2&"px;top:"&y2-2&"px;width:4px;height:4px;z-index:1' fillcolor="""&line_code(j,1)&""" strokecolor="""&line_code(j,1)&"""/>"&CHR(13)
        end select
next
    
for i=1 to total_no
    response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width+all_width*(i-1)/total_no&"px,"&table_y+all_height&"px' to='"&table_x+left_width+all_width*(i-1)/total_no&"px,"&table_y+all_height+15&"px'/>"
    response.write ""
    response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x+left_width+all_width*(i-1)/total_no&"px;top:"&table_y+all_height&"px;width:"&all_width/total_no&"px;height:18px;z-index:1'>"
    response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"&total(i,0)&"</td></tr></table></v:textbox></v:shape>"
next

tb_height=30
response.write "<v:rect id='_x0000_s1025' style='position:absolute;left:"&table_x+all_width+20&"px;top:"&table_y&"px;width:100px;height:"&line_no*tb_height+20&"px;z-index:1'/>"
for i=1 to line_no
    response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x+all_width+25&"px;top:"&table_y+10+(i-1)*tb_height&"px;width:60px;height:"&tb_height&"px;z-index:1'>"
    response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"&line_code(i,5)&"</td></tr></table></v:textbox></v:shape>"
    response.write "<v:rect id='_x0000_s1040' alt='' style='position:absolute;left:"&table_x+all_width+80&"px;top:"&table_y+10+(i-1)*tb_height+4&"px;width:30px;height:20px;z-index:1' fillcolor='"&line_code(i,1)&"'><v:fill color2='"&line_code(i,1)&"' rotate='t' focus='100%' type='gradient'/></v:rect>"
next

end function
%>
2008-09-14 18:24
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
收藏
得分:0 
[bo][un]multiple1902[/un] 在 2008-9-14 09:36 的发言:[/bo]

我感觉从数据库转换到数组似乎不难,饼图柱状图里的赋值也不会很难,关键是用什么实现饼图……

总不至于用ASP来画吧

版主,我需要的就是数据库到数组的转换啊,咋弄啊?实现饼图我倒是有现成的代码可套用(如上),可是我没有从网上找到数据库到数组的案例啊,请版主一定要指点啊,谢谢!
2008-09-16 11:19
快速回复:关于这种结果的获取:
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020635 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved