
asp一个页面同时访问两个表的内容
我要实现的目的是点击上页面列表中内容之后在aa.asp中显示这个内容的同时还要显示对这个内容的恢复内容!以下是源代码.(测试结果不显示)看一下问题所在。还要加分的!<%s...
我要实现的目的是点击上页面列表中内容之后在aa.asp中显示这个内容的同时还要显示对这个内容的恢复内容!
以下是源代码.(测试结果不显示)
看一下问题所在。还要加分的!
<%
session("subjectid")=clng(request("subjectid"))//上个页面点击之后得到"subjectid"
db="shuju/wqh.mdb"
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
%>
<%
sql="select * from subject where subjectid=" & session("subjectid")
set rs=conn.execute(sql)
%>
讨论主题
<html>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">主题:</td>
</tr>
<tr>
<td width="17%">作者:<%=rs("initiator")%></td>
<td colspan="2">时间:<%=rs("createtime")%></td>
</tr>
<tr>
<td colspan="3">内容:<%=rs("content")%></td>
</tr><%
rs.close
set rs=nothing
%>
</table>
回复内容
<%
sql1="select * from discussion where subjectid=" & session("subjectid")
set rs1=conn.execute(sql1)
%>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<%
if not rs1.eof then
%>
<tr>
<td colspan="3">标题:<%=rs1("title")%></td>
</tr>
<tr>
<td width="17%">作者:<%=rs1("answer")%></td>
<td width="83%" colspan="2">时间:<%=rs1("replytime")%></td>
</tr>
<%
rs1.movenext
wend
end if
rs1.close
conn.close
%>
</table>
</body>
</html> 展开
以下是源代码.(测试结果不显示)
看一下问题所在。还要加分的!
<%
session("subjectid")=clng(request("subjectid"))//上个页面点击之后得到"subjectid"
db="shuju/wqh.mdb"
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
%>
<%
sql="select * from subject where subjectid=" & session("subjectid")
set rs=conn.execute(sql)
%>
讨论主题
<html>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">主题:</td>
</tr>
<tr>
<td width="17%">作者:<%=rs("initiator")%></td>
<td colspan="2">时间:<%=rs("createtime")%></td>
</tr>
<tr>
<td colspan="3">内容:<%=rs("content")%></td>
</tr><%
rs.close
set rs=nothing
%>
</table>
回复内容
<%
sql1="select * from discussion where subjectid=" & session("subjectid")
set rs1=conn.execute(sql1)
%>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<%
if not rs1.eof then
%>
<tr>
<td colspan="3">标题:<%=rs1("title")%></td>
</tr>
<tr>
<td width="17%">作者:<%=rs1("answer")%></td>
<td width="83%" colspan="2">时间:<%=rs1("replytime")%></td>
</tr>
<%
rs1.movenext
wend
end if
rs1.close
conn.close
%>
</table>
</body>
</html> 展开
2个回答
展开全部
<%
sql="select * from subject where subjectid=" & session("subjectid")
set rs=conn.execute(sql)
%>
讨论主题
<html>
<body>
<%
if not rs.eof then
do while not rs.eof
%>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">主题:</td>
</tr>
<tr>
<td width="17%">作者:<%=rs("initiator")%></td>
<td colspan="2">时间:<%=rs("createtime")%></td>
</tr>
<tr>
<td colspan="3">内容:<%=rs("content")%></td>
</tr>
</table>
<%
sql1="select * from discussion where subjectid=" & rs("subjectid")
set rs1=conn.execute(sql1)
if not rs1.eof then
do while not rs1.eof
%>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">标题:<%=rs1("title")%></td>
</tr>
<tr>
<td width="17%">作者:<%=rs1("answer")%></td>
<td width="83%" colspan="2">时间:<%=rs1("replytime")%></td>
</tr>
</table>
<%
rs1.movenext
loop
end if
rs1.close
set rs1=nothing
rs.movenext
loop
end if
rs.close
set rs=nothing
conn.close
%>
</body>
</html>
楼主你这样试试看,应该可以
sql="select * from subject where subjectid=" & session("subjectid")
set rs=conn.execute(sql)
%>
讨论主题
<html>
<body>
<%
if not rs.eof then
do while not rs.eof
%>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">主题:</td>
</tr>
<tr>
<td width="17%">作者:<%=rs("initiator")%></td>
<td colspan="2">时间:<%=rs("createtime")%></td>
</tr>
<tr>
<td colspan="3">内容:<%=rs("content")%></td>
</tr>
</table>
<%
sql1="select * from discussion where subjectid=" & rs("subjectid")
set rs1=conn.execute(sql1)
if not rs1.eof then
do while not rs1.eof
%>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">标题:<%=rs1("title")%></td>
</tr>
<tr>
<td width="17%">作者:<%=rs1("answer")%></td>
<td width="83%" colspan="2">时间:<%=rs1("replytime")%></td>
</tr>
</table>
<%
rs1.movenext
loop
end if
rs1.close
set rs1=nothing
rs.movenext
loop
end if
rs.close
set rs=nothing
conn.close
%>
</body>
</html>
楼主你这样试试看,应该可以
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
缺少对应的循环语句吧。
在这里加入要循环的回复。
<%
//这里加入循环,比如
For i=1 to rs1.RecordCount
if not rs1.eof then
%>
<tr>
<td colspan="3">标题:<%=rs1("title")%></td>
</tr>
<tr>
<td width="17%">作者:<%=rs1("answer")%></td>
<td width="83%" colspan="2">时间:<%=rs1("replytime")%></td>
</tr>
<%
rs1.movenext
next //对应for
end if
rs1.close
conn.close
%>
在这里加入要循环的回复。
<%
//这里加入循环,比如
For i=1 to rs1.RecordCount
if not rs1.eof then
%>
<tr>
<td colspan="3">标题:<%=rs1("title")%></td>
</tr>
<tr>
<td width="17%">作者:<%=rs1("answer")%></td>
<td width="83%" colspan="2">时间:<%=rs1("replytime")%></td>
</tr>
<%
rs1.movenext
next //对应for
end if
rs1.close
conn.close
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询