| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 539 人关注过本帖
标题:求助!!!还是求和的问题
只看楼主 加入收藏
wwwsensen
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2005-10-31
收藏
 问题点数:0 回复次数:7 
求助!!!还是求和的问题

多些版主大哥的帮助

<%

set rs=server.CreateObject("adodb.recordset")

sql= "SELECT SUM(fdate) AS fdate,SUM(hits) AS hits from soft where fdate=2005"

rs.open sql,conn,1,1

%>
…………………………………………………………………………… {<%=rs("fdate")%> }{<%=rs("hits")%>} </td>

如何求当前页中的和,而不是整个字段中的呢??

搜索更多相关主题的帖子: 求和 
2005-10-31 13:37
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
做循环
2005-10-31 13:46
wwwsensen
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2005-10-31
收藏
得分:0 
能否说的详细一点,谢谢。

===为了明天更美好我们一起来学习===
2005-10-31 14:14
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
[QUOTE]如何求当前页中的和,而不是整个字段中的呢??[/QUOTE]
现在的源代码发上来 我看看
2005-10-31 15:12
wwwsensen
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2005-10-31
收藏
得分:0 

以下是源码,谢谢

<!--#include file="conn.asp"-->

<html><head><title>文件管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="form2" method="post" action="default1.asp">
<div align="center">
<table width="950" border="1" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border-collapse: collapse">
<tr bgcolor="#E8F1FF">
<td height="25" background="bg1.gif">&nbsp;</td>
</tr>
<tr bgcolor="#E8F1FF">
<td height="25" background="bg1.gif"> <a href="admin"><font color="#ffffff">管理员入口</font></a></td>
</tr>
<tr bgcolor="#E8F1FF">
<td height="25" background="bg1.gif">
<div align="center">
<table width="940" border="0" align="center" cellpadding="0" cellspacing="0" style="border-collapse: collapse">
<tr>
<td width="120" align="center" rowspan="2"> <select size="1" name="ztname" style="width:120">
<option selected value="0">订货单位</option>
<%
set ztrs=conn.execute("select * from zhuanti order by ztorder")
do while not ztrs.eof
%>
<option value=<%=ztrs("ztname")%>><%=ztrs("ztname")%></option>
<%
ztrs.movenext
loop
set ztrs=nothing
%>
</select></td>
</tr>
<tr>
<td width="120" height="15" align="center"> <p align="left">
<select size="1" name="guigename" style="width:120">
<option selected value="0">规格</option>
<%
set guigers=conn.execute("select * from guige order by guigeorder")
do while not guigers.eof
%>
<option value=<%=guigers("guigename")%>><%=guigers("guigename")%></option>
<%
guigers.movenext
loop
set guigers=nothing
%>
</select>
</td>
<td width="120" align="right"><select size="1" name="liduname" style="width:120">
<option selected value="0">粒度</option>
<%
set lidurs=conn.execute("select * from lidu order by liduorder")
do while not lidurs.eof
%>
<option value=<%=lidurs("liduname")%>><%=lidurs("liduname")%></option>
<%
lidurs.movenext
loop
set lidurs=nothing
%>
</select> </td>
<td width="120" align="center"> <p align="left">
<select size="1" name="jhjname" style="width:120">
<option selected value="0">结合剂</option>
<%
set jhjrs=conn.execute("select * from jhj order by jhjorder")
do while not jhjrs.eof
%>
<option value=<%=jhjrs("jhjname")%>><%=jhjrs("jhjname")%></option>
<%
jhjrs.movenext
loop
set jhjrs=nothing
%>
</select>
</td>
<td width="205" align="center"> <select name="year1" size="1">
<%for i=2000 to year(date())%>
<option value="<%=i%>"><%=i%> </option>
<%next%>
</select>

<select name="month1" size="1">
<option value="01" selected>01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>

<select name="day1" size="1">
<option value=01 selected>01</option>
<option value=02>02</option>
<option value=03>03</option>
<option value=04>04</option>
<option value=05>05</option>
<option value=06>06</option>
<option value=07>07</option>
<option value=08>08</option>
<option value=09>09</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14>14</option>
<option value=15>15</option>
<option value=16>16</option>
<option value=17>17</option>
<option value=18>18</option>
<option value=19>19</option>
<option value=20>20</option>
<option value=21>21</option>
<option value=22>22</option>
<option value=23>23</option>
<option value=24>24</option>
<option value=25>25</option>
<option value=26>26</option>
<option value=27>27</option>
<option value=28>28</option>
<option value=29>29</option>
<option value=30>30</option>
<option value=31>31</option>
</select>
日  </td>
<td width="255" align="center"> <input name="keyword" type="text" id="keyword" size="25">
&nbsp; <input type="submit" name="Submit" value="搜 索"></td>
</tr>
<tr>
<td width="120" height="15" align="center"> <select size="1" name="bigname" style="width:120">
<option selected value="0">形状</option>
<%
set bigrs=conn.execute("select * from big_class order by bigorder")
do while not bigrs.eof
%>
<option value=<%=bigrs("bigname")%>><%=bigrs("bigname")%></option>
<%
bigrs.movenext
loop
set bigrs=nothing
%>
</select></td>
<td width="120" align="center"> <p align="left">
<select size="1" name="smallname" style="width:120">
<option selected value="0">材质</option>
<%
set smallrs=conn.execute("select * from small_class order by smallorder")
do while not smallrs.eof


%>
<option value=<%=smallrs("smallname")%>><%=smallrs("smallname")%></option>
<%
smallrs.movenext
loop
set smallrs=nothing
%>
</select>
</td>
<td width="120" align="right"><select size="1" name="yingduname" style="width:120">
<option selected value="0">硬度</option>
<%
set yingdurs=conn.execute("select * from yingdu order by yingduorder")
do while not yingdurs.eof
%>
<option value=<%=yingdurs("yingduname")%>><%=yingdurs("yingduname")%></option>
<%
yingdurs.movenext
loop
set yingdurs=nothing
%>
</select> </td>
<td width="120" align="center"> <p align="left">
<select size="1" name="xsdname" style="width:120">
<option selected value="0">线速度</option>
<%
set xsdrs=conn.execute("select * from xsd order by xsdorder")
do while not xsdrs.eof
%>
<option value=<%=xsdrs("xsdname")%>><%=xsdrs("xsdname")%></option>
<%
xsdrs.movenext
loop
set xsdrs=nothing
%>
</select>
</td>
<td width="205" align="center"> <select name="year2" size="1">
<%for i=2000 to year(now())%>
<option value="<%=i%>" <%if year(now())=i then%>selected<%end if%>><%=i%></option>
<%next%>
</select>

<select name="month2">
<% if month(date())<10 then %>
<option selected value="0<%=month(date())%>">0<%=month(date())%>
<%else%>
<option selected value="<%=month(date())%>"><%=month(date())%>
<%end if%>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>

<select name="day2">
<% if day(date())<10 then %>
<option selected value="0<%=day(date())%>">0<%=day(date())%>
<%else%>
<option selected value="<%=day(date())%>"><%=day(date())%>
<%end if%>
<option value=01>01</option>
<option value=02>02</option>
<option value=03>03</option>
<option value=04>04</option>
<option value=05>05</option>
<option value=06>06</option>
<option value=07>07</option>
<option value=08>08</option>
<option value=09>09</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14>14</option>
<option value=15>15</option>
<option value=16>16</option>
<option value=17>17</option>
<option value=18>18</option>
<option value=19>19</option>
<option value=20>20</option>
<option value=21>21</option>
<option value=22>22</option>
<option value=23>23</option>
<option value=24>24</option>
<option value=25>25</option>
<option value=26>26</option>
<option value=27>27</option>
<option value=28>28</option>
<option value=29>29</option>
<option value=30>30</option>
<option value=31>31</option>
</select>
日</td>
<td width="255" align="center">&nbsp;</td>
</tr>
</table>
</div>
</td>
</tr>
<tr bgcolor="#E8F1FF">
<td height="25" background="bg1.gif"><table width="950" border="1" cellpadding="3" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#FFFFFF" style="border-collapse: collapse">
<tr>
<td width="30" align="center" bgcolor="#C0C0C0" background="images/admin_bg_1.gif">&nbsp;
</td>
<td width="100" align="center" background="images/admin_bg_1.gif" bgcolor="#C0C0C0">
<b></b></td>
<td width="180" align="center" bgcolor="#C0C0C0" background="images/admin_bg_1.gif">
<b><font color="#FFFFFF"></font></b></td>
<td width="420" align="center" bgcolor="#C0C0C0" background="images/admin_bg_1.gif"><b></b></td>
<td width="70" align="center" bgcolor="#C0C0C0" background="images/admin_bg_1.gif"><b></b></td>
</tr>
<%'开始分页
Const MaxPerPage=60
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Request("page")<>"" then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from soft where aaa=0 "
ztname=trim(request("ztname"))
bigname=trim(request("bigname"))
smallname=trim(request("smallname"))
keyword=trim(request("keyword"))
guigename=trim(request("guigename"))
liduname=trim(request("liduname"))
yingduname=trim(request("yingduname"))
jhjname=trim(request("jhjname"))
xsdname=trim(request("xsdname"))
startdate=Request("year1")&Request("month1")&Request("day1")
enddate=Request("year2")&Request("month2")&Request("day2")
stitle=request("stitle")
scontent=request("scontent")
if ztname<>"" then
if ztname<>"0" then
sql=sql&" and ztname like '%"&ztname&"%'"
end if
end if

if bigname<>"" then
if bigname<>"0" then
sql=sql&" and bigname like '%"&bigname&"%'"
end if
end if

if smallname<>"" then
if smallname<>"0" then
sql=sql&" and smallname like '%"&smallname&"%'"
end if
end if

if guigename<>"" then
if guigename<>"0" then
sql=sql&" and guigename like '%"&guigename&"%'"
end if
end if

if liduname<>"" then
if liduname<>"0" then
sql=sql&" and liduname like '%"&liduname&"%'"
end if
end if

if yingduname<>"" then
if yingduname<>"0" then
sql=sql&" and yingduname like '%"&yingduname&"%'"
end if
end if

if jhjname<>"" then
if jhjname<>"0" then
sql=sql&" and jhjname like '%"&jhjname&"%'"
end if
end if

if xsdname<>"" then
if xsdname<>"0" then
sql=sql&" and xsdname like '%"&xsdname&"%'"
end if
end if


if startdate<>"" then
sql=sql&" and fdate>="&startdate
end if

if enddate<>"" then
sql=sql&" and fdate<="&enddate
end if
if keyword<>"" then

sql=sql&" and scontent like '%"&keyword&"%' "

end if
sql=sql&" order by fdate desc "
rs.open sql,conn,1,1
if err.number<>0 then
response.write "暂无符合条件的工票!"
end if

if rs.eof And rs.bof then
Response.Write "<p align='center' > 暂无符合条件的工票!</p>"
else
totalPut=rs.recordcount

if currentpage<1 then
currentpage=1
end if

if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if

if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"default1.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"default1.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"default1.asp"
end if
end if
end if

sub showContent
dim i
i=0%>
<%do while not rs.eof%>
<tr>
<td STYLE='PADDING-LEFT: 10px'><div align="center"></div></td>
<td STYLE='PADDING-LEFT: 10px'><b><a target="_blank" href=show.asp?id=<%=rs("id")%>>
</a></b></td>
<td align="center"> <div align="left"><font color="#0000FF"><b><a target="_blank" href=show.asp?id=<%=rs("id")%>>
</a></b></font></div></td>
<td align="center"><b><a target="_blank" href=show.asp?id=<%=rs("id")%>>
</a></b></td>
<td align="center"><b><font color="#CC3300"><a href="<%=rs("softurl")%>">
</a></font><a target="_blank" href=show.asp?id=<%=rs("id")%>>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</a></b></td>
</tr>
<tr>
<td height="15" colspan="5">
<%

set rs=server.CreateObject("adodb.recordset")

sql= "SELECT SUM(fdate) AS fdate,SUM(hits) AS hits from soft where fdate=2005"

rs.open sql,conn,1,1

%>
… {<%=rs("fdate")%> }{<%=rs("hits")%>}</td>
</tr>
<tr bgcolor="#99CCFF">
<td height="15" colspan="5" align="right">
<font color="#FFFFFF" size="2">
<%
End Sub

Function showpage(totalnumber,maxperpage,filename)
Dim n

If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If
Response.Write "<p align='center' > "
If CurrentPage<2 Then
Response.Write "<font size=2>首页 上一页</font> "
Else
Response.Write "<a href="&filename&"?page=1"&"&ztname=" & ztname &"&guigename=" & guigename &"&bigname=" & bigname & "&smallname=" & smallname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword &"&stitle=" & stitle & "&scontent=" & scontent & "&yingduname=" & yingduname & "&jhjname=" & jhjname & "&xsdname=" & xsdname & "&liduname=" & liduname & " >首页</a> "
Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&ztname=" & ztname &"&guigename=" & guigename &"&bigname=" & bigname & "&smallname=" & smallname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword &"&stitle=" & stitle & "&scontent=" & scontent & "&yingduname=" & yingduname & "&jhjname=" & jhjname & "&xsdname=" & xsdname & "&liduname=" & liduname & " >上一页</a> "
End If

If n-currentpage<1 Then
Response.Write "<font size=2>下一页 尾页</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)& "&ztname=" & ztname &"&guigename=" & guigename &"&bigname=" & bigname & "&smallname=" & smallname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword &"&stitle=" & stitle & "&scontent=" & scontent & "&yingduname=" & yingduname & "&jhjname=" & jhjname & "&xsdname=" & xsdname & "&liduname=" & liduname & ">"
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&ztname=" & ztname &"&guigename=" & guigename &"&bigname=" & bigname & "&smallname=" & smallname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword &"&stitle=" & stitle & "&scontent=" & scontent & "&yingduname=" & yingduname & "&jhjname=" & jhjname & "&xsdname=" & xsdname & "&liduname=" & liduname & ">尾页</a>"
End If
Response.Write "<font size=2> 页次:</font><font size=2>"&CurrentPage&"</font><font size=2>/"&n&"页</font> "
Response.Write "<font size=2> 共有"&totalnumber&"张工票 "
End Function
%>
</font></td>
</tr>
<tr>
<td height="15" colspan="5" align="right" bgcolor="#E8F1FF">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">↑&nbsp;Top</a>&nbsp;&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</form>

</div>
</td>
</body>
</html>

<!-- this is generated by template -->


===为了明天更美好我们一起来学习===
2005-10-31 15:18
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
sub showContent
dim i
i=0
sum_fdate=0
sun_hits=0%>
<%do while not rs.eof
sum_fdate=eval(sum_fdate+rs("fdate"))
sun_hits=eval(sun_hits+rs("hits"))%>
<tr>
<td STYLE='PADDING-LEFT: 10px'><div align="center"></div></td>
<td STYLE='PADDING-LEFT: 10px'><b><a target="_blank" href=show.asp?id=<%=rs("id")%>>
</a></b></td>
<td align="center"> <div align="left"><font color="#0000FF"><b><a target="_blank" href=show.asp?id=<%=rs("id")%>>
</a></b></font></div></td>
<td align="center"><b><a target="_blank" href=show.asp?id=<%=rs("id")%>>
</a></b></td>
<td align="center"><b><font color="#CC3300"><a href="<%=rs("softurl")%>">
</a></font><a target="_blank" href=show.asp?id=<%=rs("id")%>>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</a></b></td>
</tr>
<tr>
<td height="15" colspan="5">
… {<%=sum_fdate%> }{<%=sun_hits%>}</td>
</tr>
2005-10-31 15:30
wwwsensen
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2005-10-31
收藏
得分:0 
太好了,非常感谢

===为了明天更美好我们一起来学习===
2005-10-31 16:07
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
呵呵 尽量减少重复发贴
2005-10-31 16:18
快速回复:求助!!!还是求和的问题
数据加载中...
 
   



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

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