注册 登录
编程论坛 ASP技术论坛

新手请教

幻想妖精 发布于 2008-04-14 19:21, 509 次点击
我自己写了站,首页显示标题,点击标题以后,从新窗后打开这个标题的正文部分,请问这种页面要如何用ASP编写,谢谢了

[[it] 本帖最后由 幻想妖精 于 2008-4-14 19:48 编辑 [/it]]
8 回复
#2
hebingbing2008-04-14 20:43
不写asp已经很久了,不过我觉得应该是在你的标题的链接上带上参数。内容页接受参数,查询数据库……绑定数据……显示……
#3
幻想妖精2008-04-14 21:24
这是首页我写 的  不知道对不对
<a href="file.asp?id=<%=rs("id")%>"><%=rs("biaoti")%></a>
然后是 file.asp
<%
id=request.querystring("id")
set rs=server.createobject("adodb.recordset")
ss="select id,biaoti,neirong from biaoming where id="&id
rs.open ss,conn,1,1
%>
<table>
  <tr>
   <Td><%=rs("biaoti")%></td>
  </tr>
   <tr>
   <Td><%=rs("neirong")%></td>
  </tr>
</table>
我这样写对吗

错误提示是  id= 什么的 我给忘记了
#4
frankqnj2008-04-14 22:18
举例 首页 只显示10 条
rst.open "select top 10 标题在数据库中存放字段,自动编号字段 from 表名 order by 自动编号字段 desc"  (这里倒排序 为了 得到的10条数据 是按照数据库中最新的记录来排序)
for i=1 to 10
response.write "<a href=***.asp?id=" &rst("自动编号字段")& " target=_blank>" &rst("标题字段")& "</a>"
rst.movenext
next
rst.close

然后在***.asp里
dim id
id=request.querystring("id")
rst.open "select 文章内容字段 from 表名 where 自动编号字段="&id
response.write rst("文章内容字段")
rst.close

[[it] 本帖最后由 frankqnj 于 2008-4-14 22:20 编辑 [/it]]
#5
幻想妖精2008-04-14 23:43
写写 楼上的了
但是我看 你写的和我的  思路是一样吧 ,但是 我 查看的时候出现了一个错误 等 下 我 把错误 发 出来给你看下
#6
幻想妖精2008-04-15 00:00
[bo]Microsoft JET Database Engine 错误 '80040e14'

语法错误 (操作符丢失) 在查询表达式 'id=' 中。

/file.asp,行 6[/bo]
我的源码:
<div id="left">
   <table border="0" width="480px">
     <tr>
      <td>
    <ul>
          <li><a href="file.asp?<%=rs("id")%>"><%=rs("capital")%></a></li>
    </ul>    
    </td>
</tr>
</table>
[bo]file.asp内容:[/bo]<!--#include file="include/conn.asp"-->
<%
id=request.querystring("id")
set rs=server.createobject("adodb.recordset")
sql="select capital,content from history where id="&id
rs.open sql,conn,1,1
%>
<html>
<head>
<title></title>
</head>
<body>
   <table border="0" width="800px" height="500px">
     <tr>
       <td><%=rs("capital")%></td>
     </tr>
     <tr>
        <td><%=rs("content")%></td>
     </tr>
   </table>
</body>
</html>
#7
幻想妖精2008-04-15 00:14
[bo]Microsoft JET Database Engine 错误 '80040e14'

语法错误 (操作符丢失) 在查询表达式 'id=' 中。

/file.asp,行 6[/bo]
我的源码:
<div id="left">
   <table border="0" width="480px">
     <tr>
      <td>
    <ul>
          <li><a href="file.asp?<%=rs("id")%>"><%=rs("capital")%></a></li>
    </ul>    
    </td>
</tr>
</table>
[bo]file.asp内容:[/bo]<!--#include file="include/conn.asp"-->
<%
id=request.querystring("id")
set rs=server.createobject("adodb.recordset")
sql="select capital,content from history where id="&id
rs.open sql,conn,1,1
%>
<html>
<head>
<title></title>
</head>
<body>
   <table border="0" width="800px" height="500px">
     <tr>
       <td><%=rs("capital")%></td>
     </tr>
     <tr>
        <td><%=rs("content")%></td>
     </tr>
   </table>
</body>
</html>
#8
frankqnj2008-04-15 00:42
你的file.asp内容:<!--#include file="include/conn.asp"-->
<%
id=request.querystring("id")
set rs=server.createobject("adodb.recordset")
sql="select capital,content from history where id="&id
rs.open sql,conn,1,1
%>
这部分要写到
a href="file.asp?<%=rs("id")%>"><%=rs("capital")%></a></li>

这部分 上面 . 不然asp 先执行?<%=rs("id")%>"   你还没有 连接到数据库 就想输出 数据库内容  所以才出错
#9
幻想妖精2008-04-15 02:38
哦 谢谢了 ,
少写了 加上 就正常了 、
1