王万梅教子全本:哪位大虾可以帮帮忙,有关SQL的问题

来源:百度文库 编辑:中科新闻网 时间:2024/04/26 13:42:30
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="bottom" bgcolor="#DDDDDD"><a href=more.asp?uname=<%=uname%>&id=<%=crs("id")%>><%=trim(crs("cname"))%> more...</a></td>
</tr>
<tr>
<td bgcolor="#DDDDDD" height="3" valign="top"><hr></td>
</tr>
<tr>
<td height="10"></td>
</tr>
<%
cid=Int(trim(crs("id")))
set nrs=conn.execute("select top 5 * from news where uname='"&uname&"' and categoryid="&cid&" order by id desc")
do while not nrs.eof

a_time=FormatDateTime(nrs("news_time"))
if Len(minute(a_time))=1 then
a_minute="0"&minute(a_time)
else
a_minute=minute(a_time)
end if
%>
<tr>
<td><a href="readnews.asp?uname=<%=uname%>&newsid=<%=trim(nrs("id"))%>"><%=trim(nrs("title"))%></a> <font color="#999999">(<%=year(a_time)&"年"&month(a_time)&"月"&day(a_time)&"日 "&hour(a_time)&":"&a_minute%>)</font></td>
</tr>
<tr>
<td height="8"></td>
</tr>
<%
nrs.movenext
Loop
%>
</table>
<%
crs.movenext
Loop
crs.close
%>
能详细点告诉我意思吗?
谢谢
呵呵,一会给啦,拜托了
可是就那么一点点10分,心痛啊
会给的啦,老大
能具体点?
谢谢了

1.这是一个新闻发布页面,是个首页.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="bottom" bgcolor="#DDDDDD"><a href=more.asp?uname=<%=uname%>&id=<%=crs("id")%>><%=trim(crs("cname"))%> more...</a></td> '显示more一个链接,指向详细的新闻发布面面.
</tr>
<tr>
<td bgcolor="#DDDDDD" height="3" valign="top"><hr></td>
</tr>
<tr>
<td height="10"></td>
</tr>
<%
cid=Int(trim(crs("id"))) '获取新闻id号,存入变量cid
set nrs=conn.execute("select top 5 * from news where uname='"&uname&"' and categoryid="&cid&" order by id desc")'查找前五个新闻记录,存入记录集nrs中.
do while not nrs.eof '当nrs记录集不为空

a_time=FormatDateTime(nrs("news_time")) '取得新闻发布的时间
if Len(minute(a_time))=1 then '如果时间分长度为1,即分钟小于10
a_minute="0"&minute(a_time) '在分钟前别0,比如分钟为6就是06
else
a_minute=minute(a_time) '如果不小于10,直接存入.
end if
%>
<tr>
<td><a href="readnews.asp?uname=<%=uname%>&newsid=<%=trim(nrs("id"))%>"><%=trim(nrs("title"))%></a> <font color="#999999">(<%=year(a_time)&"年"&month(a_time)&"月"&day(a_time)&"日 "&hour(a_time)&":"&a_minute%>)</font></td>
'显示是一个新闻标题+新闻时间,链接地址:readners.asp?uname=?(数据库里uname表示什么我不知道,得看到原数据库才能知道,可能是新闻分类名称)&newsid=新闻序号
</tr>
<tr>
<td height="8"></td>
</tr>
<%
nrs.movenext
Loop
%>
</table>
<%
crs.movenext
Loop
crs.close
%>

整个显示页面是这样的(注:新闻1表示第一条新闻标题,以下类推):
more..

新闻1 时间
新闻2 时间
新闻3 时间
新闻4 时间
新闻5 时间