ASP如何将数据库的数据倒过来读出来显示?(产品编号)
我公司的网站数据库编号排列是从小到大顺序排列的。但是有个麻烦的问题就是我传上去的新产品总是在最后一页显示。这样很麻烦。老板要求新产品传上去后总是显示在第一页!ASP的高手...
我公司的网站 数据库编号排列是从小到大顺序排列的。
但是有个麻烦的问题 就是我传上去的新产品总是在最后一页显示。
这样很麻烦。 老板要求新产品传上去后总是显示在第一页!
ASP的高手 大哥 大姐 帮帮小弟吧 拜托~! 谢谢
问题解决了 我附送100分!绝不食言!
<!-- #include file="conn.asp" -->
<%set rs=server.CreateObject("adodb.recordset")
cataid=trim(request("cataid"))
if request("page")<>"" then
AbsolutePage1=cint(request("page"))
else
AbsolutePage1=1
end if
dim level,rootid
if cataid="" then
level=0
rootid=0
else
sql="select * from type where typeid="&cint(cataid)
rs.open sql,conn,1,1
level=rs("level")
rs.close
rootid=cint(cataid)
end if
if rootid=0 then
sql="select * from type where level="&level+1&" order by typeid"
else
m=len(cstr(rootid))
n=(level-1)*(m+1)+1
sql="select * from type where level="&level+1&" and mid(rootid,"&n&","&m&")='"&cstr(rootid)&"' order by typeid"
end if
'response.Write(sql)
'response.end
rs.open sql,conn,1,1
if rs.eof or rs.bof then
set rsp=server.CreateObject("adodb.recordset")
sql="select * from chanpin where lock=0 and typeid="&cint(trim(request("cataid")))&" order by sortid"
rsp.open sql,conn,3,1
if rsp.eof or rsp.bof then
response.write("<br><br><div align=center>NO PRODUCTS<br><br><br><br><br></div>")
PageCount1=1
recordcount1=0
pagesize1=0
else
PageSize1=9
rsp.pagesize=pagesize1
rsp.absolutepage=AbsolutePage1
PageCount1=rsp.PageCount
if pagecount1=0 then pagecount1=1
recordcount1=rsp.recordcount
%>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<%for i= 1 to pagesize1
cpname=rsp("cpname")
if len(cpname)>15 then
cpname=left(cpname,14)&".."
end if
if i mod 3=1 then
%>
<tr align="center">
<%end if%>
<td width="25%"><a href="#" title="<%=rsp("cpname")%>" onClick="MM_openBrWindow('product_show.asp?id=<%=rsp("id")%>','kaibotrade',' width=800,height=600')"><img src="proimg/<%=rsp("cpimg")%>" width="160" hspace="3" vspace="5" border="0"></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="center"><%=rsp("cpname")%></td>
</tr>
</table> </td>
<%rsp.movenext
if rsp.eof then exit for
if i mod 3=0 then%>
</tr>
<%end if
next
%>
</table>
<%end if
rsp.close
set rsp=nothing
else
PageSize1=9
rs.pagesize=pagesize1
rs.absolutepage=AbsolutePage1
PageCount1=rs.PageCount
if pagecount1=0 then pagecount1=1
recordcount1=rs.recordcount
%>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="5">
<%for i= 1 to pagesize1
if i mod 3=1 then
%>
<tr>
<%end if%>
<td width="25%" align="center" valign="middle"> <a href="product.asp?cataid=<%=rs("typeid")%>"> <img src="proimg/<%=rs("typeimg") %>" width="160" hspace="5" vspace="5" border="0"></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="center"><a href="product.asp?cataid=<%=rs("typeid")%>"><%=rs("type")%></a></td>
</tr>
</table>
<a href="product.asp?cataid=<%=rs("typeid")%>">
</a></td>
<%rs.movenext
if rs.eof then exit for
if i mod 3=0 then%>
</tr>
<%end if
next%>
</table>
<%end if
rs.close
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center>
<tr>
<%filename="product.asp"%>
<form method=Post action="<%=filename%>?cataid=<%=request("cataid")%>"><td height="20" align="right" nowrap >Total<b> <%=recordcount1%> </b>Products Eachpage<b> <%=pagesize1%> </b>Pcs 展开
但是有个麻烦的问题 就是我传上去的新产品总是在最后一页显示。
这样很麻烦。 老板要求新产品传上去后总是显示在第一页!
ASP的高手 大哥 大姐 帮帮小弟吧 拜托~! 谢谢
问题解决了 我附送100分!绝不食言!
<!-- #include file="conn.asp" -->
<%set rs=server.CreateObject("adodb.recordset")
cataid=trim(request("cataid"))
if request("page")<>"" then
AbsolutePage1=cint(request("page"))
else
AbsolutePage1=1
end if
dim level,rootid
if cataid="" then
level=0
rootid=0
else
sql="select * from type where typeid="&cint(cataid)
rs.open sql,conn,1,1
level=rs("level")
rs.close
rootid=cint(cataid)
end if
if rootid=0 then
sql="select * from type where level="&level+1&" order by typeid"
else
m=len(cstr(rootid))
n=(level-1)*(m+1)+1
sql="select * from type where level="&level+1&" and mid(rootid,"&n&","&m&")='"&cstr(rootid)&"' order by typeid"
end if
'response.Write(sql)
'response.end
rs.open sql,conn,1,1
if rs.eof or rs.bof then
set rsp=server.CreateObject("adodb.recordset")
sql="select * from chanpin where lock=0 and typeid="&cint(trim(request("cataid")))&" order by sortid"
rsp.open sql,conn,3,1
if rsp.eof or rsp.bof then
response.write("<br><br><div align=center>NO PRODUCTS<br><br><br><br><br></div>")
PageCount1=1
recordcount1=0
pagesize1=0
else
PageSize1=9
rsp.pagesize=pagesize1
rsp.absolutepage=AbsolutePage1
PageCount1=rsp.PageCount
if pagecount1=0 then pagecount1=1
recordcount1=rsp.recordcount
%>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<%for i= 1 to pagesize1
cpname=rsp("cpname")
if len(cpname)>15 then
cpname=left(cpname,14)&".."
end if
if i mod 3=1 then
%>
<tr align="center">
<%end if%>
<td width="25%"><a href="#" title="<%=rsp("cpname")%>" onClick="MM_openBrWindow('product_show.asp?id=<%=rsp("id")%>','kaibotrade',' width=800,height=600')"><img src="proimg/<%=rsp("cpimg")%>" width="160" hspace="3" vspace="5" border="0"></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="center"><%=rsp("cpname")%></td>
</tr>
</table> </td>
<%rsp.movenext
if rsp.eof then exit for
if i mod 3=0 then%>
</tr>
<%end if
next
%>
</table>
<%end if
rsp.close
set rsp=nothing
else
PageSize1=9
rs.pagesize=pagesize1
rs.absolutepage=AbsolutePage1
PageCount1=rs.PageCount
if pagecount1=0 then pagecount1=1
recordcount1=rs.recordcount
%>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="5">
<%for i= 1 to pagesize1
if i mod 3=1 then
%>
<tr>
<%end if%>
<td width="25%" align="center" valign="middle"> <a href="product.asp?cataid=<%=rs("typeid")%>"> <img src="proimg/<%=rs("typeimg") %>" width="160" hspace="5" vspace="5" border="0"></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="center"><a href="product.asp?cataid=<%=rs("typeid")%>"><%=rs("type")%></a></td>
</tr>
</table>
<a href="product.asp?cataid=<%=rs("typeid")%>">
</a></td>
<%rs.movenext
if rs.eof then exit for
if i mod 3=0 then%>
</tr>
<%end if
next%>
</table>
<%end if
rs.close
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center>
<tr>
<%filename="product.asp"%>
<form method=Post action="<%=filename%>?cataid=<%=request("cataid")%>"><td height="20" align="right" nowrap >Total<b> <%=recordcount1%> </b>Products Eachpage<b> <%=pagesize1%> </b>Pcs 展开
展开全部
把
sql="select * from chanpin where lock=0 and typeid="&cint(trim(request("cataid")))&" order by sortid"
这句改成
sql="select * from chanpin where lock=0 and typeid="&cint(trim(request("cataid")))&" order by sortid desc"
sql="select * from chanpin where lock=0 and typeid="&cint(trim(request("cataid")))&" order by sortid"
这句改成
sql="select * from chanpin where lock=0 and typeid="&cint(trim(request("cataid")))&" order by sortid desc"
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在sql语句中加desc,
例如 select * from type where level="&level+1&" order by typeid desc
例如 select * from type where level="&level+1&" order by typeid desc
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询