新手请教如何写SQL语句来实现"通过点击主题到-->显示主题内容"?
我想问通过点击"主题"到显示主题内容过程中,id参数是如何传递到显示主题内容的界面,主题到显示主题内容是怎样的连接关系?谢谢大家帮忙!
time.asp-->query.asp-->liuyan.asp
前两者已通过,就是从query.asp-->liuyan.asp还不知如何去实现
query.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--#include file="newconn.asp"-->
<HTML>
<HEAD>
<TITLE>查询结果显示</TITLE>
<%
'取年月日的值
if Request.Form("btnSumit") <> "" then
dim BegTime,EndTime
BegTime = Request.Form("by") & "-" & Request.Form("bm") & "-" & Request.Form("bd")
EndTime = Request.Form("ey") & "-" & Request.Form("em") & "-" & Request.Form("ed")
Sql="select id,subject,content,dateandtime from info where dateandtime between cdate('" & BegTime & "') and cdate('" & EndTime & "') order by id desc"
session("sql")=sql
else
sql=session("sql")
end if
Set rs=Server.createobject("ADODB.Recordset")
rs.open sql,conn,1,1
If Request("Page")="" Then
Page=1
else
Page = CLng(Request("Page")) ' CLng 不可省略,用于将页码转换为长整型
end if
if not rs.eof then
allcount=rs.recordcount
rs.pagesize=4
pagec=cInt(rs.pagecount)
rs.Absolutepage=page
%>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<form>
<table width="60%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center" height="32">
<tr bgcolor="#FFFFFF">
<td height="20" width="22%">
<div align="center"><font size="2">主题</font></div>
</td>
<td height="20" width="54%">
<div align="center"><font size="2">内容</font></div>
</td>
<td height="20" width="24%">
<div align="center"><font size="2">时间</font></div>
</td>
</tr>
</table>
<%
'rs.AbsolutePage=Page
For iPage = 1 To rs.PageSize '输出当前页的所有记录
%>
<table width="60%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center" height="32">
<tr bgcolor="#FFFFFF">
<%' RecNo = (Page - 1) * rs.PageSize + iPage %>
<td height="20" width="22%">
<div align="center"><font size="2"><a href="liuyan.asp?id=<%=rs(0)%>"><%=rs(1)%></a></font></div>
</td>
<td height="20" width="54%">
<div align="center"><font size="2"><%=rs(2)%></font></div>
</td>
<td height="20" width="24%">
<div align="center"><font size="2"><%=rs(3)%></font></div>
</td>
</tr>
<%
rs.MoveNext
If rs.EOF Then Exit For
next
%>
</table>
<table width="60%" border=0 cellspacing=1 cellpadding=0 bgcolor=#000000 align=center height=32>
<tr bgcolor=#FFFFFF>
<td >
<div align="center">
<% If Page <> 1 Then%>
<A HREF="query.asp?Page=1&BegTime=<%=BegTime%>&EndTime=<%=Endtime%>">
<font size="2">第一页</font></A> <font size="2"><A HREF="query.asp?Page=<%=(Page-1)%>&BegTime=<%=BegTime%>&EndTime=<%=Endtime%>">上一页</A></font>
<%End If%>
<%If Page <>PageC Then %>
<A HREF="query.asp?Page=<%=(Page+1)%>&BegTime=<%=BegTime%>&EndTime=<%=Endtime%>"><font size="2">下一页</font></A>
<font size="2"><A HREF="query.asp?Page=<%=PageC%>&BegTime=<%=BegTime%>&EndTime=<%=Endtime%>">最后一页</A></font>
<%End If%>
</div>
</td></tr></table>
<p align="center">输入页数:
<input type="text" size="3" name="Page" value=<%=page%>>
页数:<font color="#FF0000"><%=Page%>/<%=PageC%> <a href="time.asp"><font size="2" color="#0066FF">回到查询界面</font></a>
</font></p>
</form>
<%else%>
<table width="60%" border=0 cellspacing=1 cellpadding=0 bgcolor=#000000 align=center height=32 bordercolor="#FFFFFF">
<tr bgcolor=#FFFFFF>
<td colspan=3 align=center height=30 bgcolor="#FFFFFF"><font color=red>没有找到任何记录</font></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<div align="center"><a href="time.asp"><font size="2" color="#0066FF">回到查询界面</font></a></div>
</td>
</tr>
</table>
<%end if%>
</BODY>
</HTML>
liuyan.asp
<!--include file="newconn.asp" -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
sql="select subject,content from info where id="&id&""
response.write sql
response.end
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center"> <b><font color="#0000FF">& <font color="#CC3300">管理员留言
</font>& </font></b>
<form name="form1" method="post" action="">
<table width="39%" border="0" cellspacing="1" cellpadding="0" height="116" bgcolor="#990066">
<tr>
<td bgcolor="#FFFFFF" width="22%" height="18">
<div align="right"><font color="#0000FF" size="2">主题:</font></div>
</td>
<td bgcolor="#FFFFFF" width="78%" height="18"><%=rs(0)%></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="22%" height="22">
<div align="right"><font size="2" color="#0000FF">内容:</font></div>
</td>
<td bgcolor="#FFFFFF" width="78%" height="22" valign="top"><%=rs(1)%></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="22%" height="44">
<div align="right"><font size="2" color="#0000FF">回复主题:</font></div>
</td>
<td bgcolor="#FFFFFF" width="78%" height="44">
<div align="left">
<textarea name="textfield"></textarea>
</div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="22%" height="15"> </td>
<td bgcolor="#FFFFFF" width="78%" height="15">
<div align="center">
<input type="submit" name="Submit" value="提交">
<input type="submit" name="Submit2" value="清除">
</div>
</td>
</tr>
</table> </form>
<p> </p>
</div>
</body>
</html>