中国站长论坛

中国站长论坛 ›› 网络编程 ›› [求助]一个ASP下载中心乱序的问题?

页码: 1

[求助]一个ASP下载中心乱序的问题?

- leanpig 2008-08-12 10:04

下载中心的文件添加到16个以后就乱序了,不按照倒序的方式顺着排了。这是怎么回事呢?请高手指点迷津,谢谢。

这个是嵌套文件代码:SysDown.asp

<META http-equiv=Content-Type content="text/html; charset=gb2312">
<!--#Include File="Check_Sql.asp"-->
<!--#include file="Conn.asp"-->
<!--#include file="Config.asp"-->
<!--#include file="Function.asp"-->
<%
dim strFileName,MaxPerPage,ShowSmallClassType
dim totalPut,CurrentPage,TotalPages
dim BeginTime,EndTime
dim founderr, errmsg
dim BigClassName,SmallClassName,keyword,strField
dim rs,sql,sqlDown,rsDown,sqlSearch,rsSearch,sqlBigClass,rsBigClass,sqlBigClass_Down
BeginTime=Timer
BigClassName=Trim(request("BigClassName"))
SmallClassName=Trim(request("SmallClassName"))
keyword=trim(request("keyword"))
if keyword<>"" then
 keyword=replace(replace(replace(replace(keyword,"'","‘"),"<","&lt;"),">","&gt;")," ","&nbsp;")
end if
strField=trim(request("Field"))

if request("page")<>"" then
   currentPage=cint(request("page"))
else
currentPage=1
end if

sqlBigClass_Down="select * from BigClass_Down order by BigClassID"
Set rsBigClass_Down= Server.CreateObject("ADODB.Recordset")
rsBigClass_Down.open sqlBigClass_Down,conn,1,1
%>

<%
'=================================================
'过程名:ShowSmallClass_Down_Tree
'作  用:树形目录方式显示栏目
'参  数:无
'=================================================
sub ShowSmallClass_Down_Tree()
%>
<SCRIPT language=javascript>
function opencat(cat,img){
if(cat.style.display=="none"){
cat.style.display="";
img.src="img/class2.gif";
} else{
cat.style.display="none";
img.src="img/class1.gif";
}
}
</Script>
<TABLE cellSpacing=0 cellPadding=0 width="99%" border=0>
<%
dim i
set rsbigdown = server.CreateObject ("adodb.recordset")
sql="select * from BigClass_down"
rsbigdown.open sql,conn,1,1
if rsbigdown.eof and rsbigdown.bof then
Response.Write "栏目正在建设中……"
else
i=1
do while not rsbigdown.eof
%>
<TR>
 <TD language=javascript onmouseup="opencat(cat10<%=i%>000,&#13;&#10; img10<%=i%>000);" id=item$pval[catID]) style="CURSOR: hand" width=34 height=24 align=center><IMG id=img10<%=i%>000 src="img/class1.gif" width=20 height=20></TD>
 <TD width="662"><a href='download.asp?BigClassName=<%=rsbigdown("BigClassName")%>'><%=rsbigdown("BigClassName")%></a></TD>
</TR>
<TR>
 <TD id=cat10<%=i%>000 <%if rsbigdown("BigClassName")=BigClassName then
      response.write "style='DISPLAY'"  
     else
      response.write "style='DISPLAY: none'"
     end if%> colspan="2">
<%
dim rsSmall,sqls,j
set rsSmall = server.CreateObject ("adodb.recordset")
sqls="select * from SmallClass_down where BigClassName='" & rsbigdown("BigClassName") & "' order by SmallClassID"
rsSmall.open sqls,conn,1,1
if rsSmall.eof and rsSmall.bof then
Response.Write "没有小类"
else
j=1
do while not rsSmall.eof
%>
&nbsp;<IMG height=20 src="img/class3.gif" width=26 align=absMiddle border=0><a href="download.asp?BigClassName=<%=rsSmall("BigClassName")%>&Smallclassname=<%=rsSmall("SmallClassName")%>"><%=rsSmall("SmallClassName")%></a><BR>
<%
rsSmall.movenext
j=j+1
loop
end if
rsSmall.close
set rsSmall=nothing
%>
 </TD>
</TR>
<%
rsbigdown.movenext
i=i+1
loop
rsbigdown.close
   set rsbigdown=nothing
end if
%>
</TABLE>
<%
end sub
%>

<%
'=================================================
'过程名:ShowClass_DownGuide
'作  用:显示栏目导航位置
'参  数:无
'=================================================
sub ShowClass_DownGuide()
response.write  "&nbsp;<a href='download.asp'>下载</a>&nbsp;&gt;&gt;"
if BigClassName="" and SmallClassName="" then
 response.write "&nbsp;所有下载"
else
 if BigClassName<>"" then
  response.write "&nbsp;<a href='Download.asp?BigClassName=" & BigClassName & "'>" & BigClassName & "</a>&nbsp;&gt;&gt;&nbsp;"
  if SmallClassName<>"" then
   response.write "<a href='Download.asp?BigClassName=" & BigClassName & "&SmallClassName=" & SmallClassName & "'>" & SmallClassName & "</a>"
  else
   response.write "所有小类"
  end if
 end if
end if
end sub

'=================================================
'过程名:ShowDownTotal
'作  用:显示文章总数
'参  数:无
'=================================================
sub ShowDownTotal()
dim sqlTotal
dim rsTotal
sqlTotal="select Count(*) from download "
if BigClassName<>"" then
 sqlTotal=sqlTotal & " where BigClassName='" & BigClassName & "' "
 if SmallClassName<>"" then
  sqlTotal=sqlTotal & " and SmallClassName='" & SmallClassName & "' "
 end if
end if
Set rsTotal= Server.CreateObject("ADODB.Recordset")
rsTotal.open sqlTotal,conn,1,1
if rsTotal.eof and rsTotal.bof then
 totalPut=0
 response.write "共有 0 个下载"
else
 totalPut=rsTotal(0)
 response.Write "共有 " & totalPut & " 个下载"
end if
rsTotal.close
set rsTotal=nothing
end sub

'=================================================
'过程名:ShowDown
'=================================================
sub ShowDown(TitleLen)
if TitleLen<0 or TitleLen>200 then
 TitleLen=50
end if
   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
       sqlDown="select top " & MaxPerPage
else
 sqlDown="select "
end if

sqlDown=sqlDown & " ID,title,content,BigClassName,SmallClassName,System,Language,Softclass,PhotoUrl,DownloadUrl,FileSize,Hits,AddDate from download"

if BigClassName<>"" then
 sqlDown=sqlDown & " where BigClassName='" & BigClassName & "' "
 if SmallClassName<>"" then
  sqlDown=sqlDown & " and SmallClassName='" & SmallClassName & "' "
 end if
end if
sqlDown=sqlDown & " order by AddDate desc"
Set rsDown= Server.CreateObject("ADODB.Recordset")
rsDown.open sqlDown,conn,1,1
if rsDown.bof and  rsDown.eof then
 response.Write("<br><li>没有任何下载</li>")
else
 if currentPage=1 then
  call DownContent(TitleLen)
 else
  if (currentPage-1)*MaxPerPage<totalPut then
             rsDown.move  (currentPage-1)*MaxPerPage
          dim bookmark
            bookmark=rsDown.bookmark
            call DownContent(TitleLen)
        else
         currentPage=1
            call DownContent(TitleLen)
     end if
 end if
end if
rsDown.close
set rsDown=nothing
end sub

sub DownContent(intTitleLen)
   dim i,strTemp
   i=0
do while not rsDown.eof
 strTemp=""
 strTemp=strTemp & "<table width=98% border=0 cellSpacing=1 cellpadding=3>"
  strTemp=strTemp & "<tr><td width=60% height=30>"
  strTemp=strTemp & "<a href=DownloadShow.asp?ID=" & rsDown("ID") & ">&nbsp;<b>" & rsDown("Title") & "</b></a>"
  strTemp=strTemp & "</td>"
  strTemp=strTemp & "<td align=right><a href=" & rsDown("DownloadUrl") & " target=_blank><FONT COLOR=#0000FF>下载</FONT></a> |&nbsp;"
  strTemp=strTemp & "<a href=DownloadShow.asp?ID=" & rsDown("ID") & "><FONT COLOR=#0000FF>说明</FONT></a>&nbsp;&nbsp;</a>&nbsp;" & "(&nbsp;" & FormatDateTime(rsDown("AddDate"),2) & "&nbsp;)"
  strTemp=strTemp & "</td></tr>"
  strTemp=strTemp & "<tr><td height=1 colspan=2 bgcolor=#CCCCCC></td>"
  strTemp=strTemp & "</tr></table>"
 response.write strTemp
 rsDown.movenext
 i=i+1
 if i>=MaxPerPage then exit do
loop
end sub

Re:[求助]一个ASP下载中心乱序的问题?

- dan001 2008-08-18 14:38

倒序是 order by * desc 不是asc
你在asp里写sql语句,默认排序是 asc,是从小到大
你如果要从大到小必须要写上 desc 不能把后面省略了。
类似的
order by BigClassID
改成
order by BigClassID desc

Re:[求助]一个ASP下载中心乱序的问题?

- dai_js 2008-08-19 01:00

同意楼上的

Re:[求助]一个ASP下载中心乱序的问题?

- yysyya 2008-09-08 13:33

这种简单的SQL语句还是要懂得  你网站源码下载的吧  





万能拉力试验机|环境试验机|万能拉力试验机

Re:[求助]一个ASP下载中心乱序的问题?

- sbmc4 2008-09-09 09:04

太多了。。。

页码: 1