当前位置:编程学习 > asp >>

asp里,如果使代码按时间的先后排列

<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>评论-显示</title>
<link rel="stylesheet" href="js/top.css" type="text/css" />
<style type="text/css">
<!--
.style1 {font-size: 12px}
-->
</style>
</head>

<body>
<div align="center">
<span class="style1">
<%
dim rs1
if request.querystring("id")="" or request.querystring("id")="0" then
response.write "暂时没有任何评论"
else
set rs1=server.CreateObject("adodb.recordset")
sql_rs1="select shop_pinglun.*,User.UserName as name1 from shop_pinglun,User where shop_pinglun.user_id=User.id and shop_pinglun.ID="&request.querystring("id")&""
rs1.open sql_rs1,conn,1,1
if rs1.bof or rs1.eof then
response.write "暂时没有任何评论"
else
do while not rs1.eof
%>
</span>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#FFFFFF" class="style1">
<td width="27%" height="22" align="center">会员 - <%=rs1("name1")%></td>
<td width="59%" height="22"><%=rs1("pingluncontent")%></td>
<td width="14%" height="22" align="center"><%=rs1("pinglundate")%></td>
</tr>
<tr bgcolor="#CCCCCC">
<td height=1></td>
<td></td>
<td></td>
</tr>
<%
rs1.movenext
loop
rs1.close
set rs1=nothing
end if
end if
%>
</table>
</div>
</body>
</html>

数据库里的时间列是 pinglundate

如上面,我的一个评论程序,评论之支是按照会员的ID排列先后的,我想使它按时间先后排列,知道的人,速度回答一下。。
答案:
根据评论时间来排列撒。改变
sql_rs1="select shop_pinglun.*,User.UserName as name1 from shop_pinglun,User where shop_pinglun.user_id=User.id and shop_pinglun.ID="&request.querystring("id")&""
将 and shop_pinglun.ID="&request.querystring("id")&" 改
order by idate desc "idate"改为你这个数据表的评论时间字段
sql_rs1="..."一行修改为
sql_rs1="select shop_pinglun.*,User.UserName as name1 from shop_pinglun,User where shop_pinglun.user_id=User.id and shop_pinglun.ID="&request.querystring("id")&" order by shop_pinglun.pinglundate"

上一个:asp中的代码出现乱码,不知是哪里出错了。请高手指点
下一个:用asp等代码写的重定向和在iis上设置有什么不一样吗?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,