诚望指教

stone_ho 2005-11-17 12:45:36
<%openproductnews
dim totalart,Currentpage,totalpages,j,colname,cid,key,temp,cid1,mdim,depth,spacebar

nummer=40


cid=request("c_id")
key=request("keyword")
action=request("action")
if request("c_id")<>"" then
sql="select * from class where cid="&request("c_id")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
mdim=""
depth=rs("depth")
temp=""
sql="select * from class where depth>="&depth
set rs1=server.createobject("adodb.recordset")
rs1.open sql,conn,1,1
do while not rs1.eof
temp=split(rs1("id_code"),",")
if cid=temp(depth) then
if mdim="" then
mdim=rs1("cid")
else

mdim=mdim&","&rs1("cid")
end if
end if
rs1.movenext
loop


mdim=split(mdim,",")

spacebar=" "
sql="("
for i=0 to ubound(mdim)
if i<>ubound(mdim) then
spacebar=" or "
else
spacebar=" "
end if
sql=sql&"cid="&mdim(i)&spacebar

next
sql=sql&" ) and depth>="&depth&" "

end if
if request("keyword")<>"" then
if sql<>"" then
'sql=sql&"where name like '%"&key&"%' or content like '%"&key&"%'"
sql=sql&" and name like '%"&key&"%' "
else
sql= " name like '%"&key&"%' "
end if
end if

if sql <>"" then
sql="select * from news where "&sql&" order by id desc"
else
sql="select * from product order by id desc"
end if

pageurl="?c_id="&cid&"&s_id="&sid&"&action="&action&"&keyword="&key&"&"
session("pageurl")="?c_id="&cid&"&s_id="&sid&"&action="&action&"&keyword="&key&"&"


'response.Write sql

set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then

rssum=rs.recordcount
end if
call format_pagecute("2")
if not rs.eof then
temp=split(rs("id_code"),",")
aspname=int(temp(0))
sql="select * from class where cid="&aspname
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
end if
%>

数据库openproductnews有两个表分别为class和news
class有字段(cid,pid,cname,depth,cid_order,id_code)
news有字段(id,cid,name,pic,content,depth,depth,id_code,pro_date,cid_order等)
上面的程式是用(?=)取得数据,如果我想在首页或者没有(?=)的情况下取得数据并显示,程式该如何写?
(比如在首页上显示最近上传的五条新闻的标题并链连)
本人门口水平,请各位指教!
...全文
118 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
stone_ho 2005-11-18
  • 打赏
  • 举报
回复
<a href=# onclick=window.open("xxx.asp?id=<%=id%>")>aaa</a>
stone_ho 2005-11-17
  • 打赏
  • 举报
回复
<a href="xxx.asp?id=<%=rs("id")%> target=_blank><%=rs("name")%></a>

xxx.asp也就是子模板名相对应的表是class中的cname,需要根据news中的id从class中查找
stone_ho 2005-11-17
  • 打赏
  • 举报
回复
顶一顶
piperzero 2005-11-17
  • 打赏
  • 举报
回复
比如在首页上显示最近上传的五条新闻的标题并链连
set rs=server.createobject("adodb.recordset")
sql="select top 5 * from news order by id desc"
rs.opeb sql,conn,1,3
显示新闻
<a href="xxx.asp?id=<%=rs("id")%> target=_blank><%=rs("name")%></a>

PS,你的news表中有相同的字段名,应该时你打错了

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧