1。怎么写调用数据库部分栏目(部分二级栏目);2。如何通过数据库实现下拉的菜单(包含二,三级栏目)

3851391 2004-11-25 12:40:56


我用的是http://www.wenday.com的网站信息系统,在那里提问,好几天都没人回答。
请社区的朋友帮帮忙,我急啊!每个问题50分,得到答案,马上结帖给分。

1。怎么写调用数据库部分栏目的文章(部分二级栏目);

以下是代码:
<%
dim sqlsort
dim RsSort
sqlsort="select * from Sort where B_id=0 and setting < 4 order by S_order"
Set RsSort=conn.execute (sqlsort)
if RsSort.eof and RsSort.bof then
response.write "<div align=center>还没有任何栏目</div>"
else
do while not RsSort.eof
%> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<TD width="6%" background=Img/Ew_BarBg.gif height=34>
<img src="Img/Ew_Bar.gif" width="55" height="34"></TD>
<TD width="94%" background=Img/Ew_BarBg.gif><a href="Sort.asp?SortID=<%=RsSort(0)%>"><%=RsSort(1)%></a></TD>
</TR>
</TABLE>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="35%" height="106" align="center">
<%
set RsPic=server.createobject("adodb.recordset")
sql="select top 1 * from Info where Sort1="&RsSort("id")&" and Ispic=1 ORDER BY ADDdate desc,id DESC"
RsPic.open sql,conn,1,1
if RsPic.eof or RsPic.bof then
Call NoPic("本类暂无图文信息")
end if
do while not RsPic.eof

Call Ew_ShowPic(RsPic("Pic"),RsPic(0),RsPic("Title"),140,110,17)

RsPic.movenext
loop
RsPic.close
set RsPic=nothing
%> </td>
<td width="65%" valign="top"> <% Call Ew_ShowInfo(5,Sort_Count,35,RsSort("id"),1) %> </td>
</tr>
</table>
<%
RsSort.movenext
loop
end if
RsSort.close
set RsSort=nothing
%>

2。如何通过数据库实现下拉的菜单(包含二,三级栏目)
差不多 http://emba.gsm.pku.edu.cn/的风格,但要加(半透明的)下拉菜单
以下是代码:
<%
sql="select * from Sort where B_id=0 order by s_order"
Set rs=conn.execute (sql)
if rs.eof and rs.bof then
response.write "没有栏目"
else
do while not rs.eof
Id=Request("SortID")
%>
<td align="center"><a href="Sort.asp?SortID=<%=rs("ID")%>">
<%if rs("id")=id then%>
<font color=#FF0000><%=rs("Names")%></font>
<%else%>
<%=rs("Names")%>
<%end if%>
</a></td>
<%
rs.movenext
loop
end if
rs.close
%>
...全文
141 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
3851391 2004-11-28
  • 打赏
  • 举报
回复
下面是调用热门文章的函数;
第二参数:nums 数字表示调条的条数
第三参数:Linenum 数字表示每条的显示字数
第四参数:S_info 不知道
第五参数:Show_date 0不显示时间;1显示时间
================================================
<% Call Ew_ShowInfo(1,3,26,0,1) %>
=================================================
但如果写二级栏目的调用文章函数?向这样的调用?!
-------------------------------------------------------
数据库的结构:
INFO表的字段:
ID(自动) Title content discussion(1讨论, 0不许) sort1 sort2 pic key
1 标题1 内容1 0 1 27
2 标题2 内容2 0 1 26
3 标题3 内容3 0 1 28
4 标题4 内容4 0 6 12
5 标题5 内容5 0 6 13
6 标题6 内容6 0 6 14

Sort表的字段 (同类型排序) (大类为一级时分页 Setting=3)
ID(自动) Names B_ID S_Order Setting Info Addtime Hit
1 一级栏目1 0 0 1 2004年11月9日
6 一级栏目2 0 0 1 2004年11月9日
7 一级栏目3 0 0 1 2004年11月9日
8 一级栏目4 0 0 1 2004年11月9日
11 一级栏目2(小类) 6 0 3 2004年11月9日
12 一级栏目2(小类) 6 1 3 2004年11月9日
13 一级栏目2(小类) 6 2 3 2004年11月9日
-------------------------------------------------------
Function Ew_ShowInfo(s_num,nums,Linenum,S_info,Show_date)
response.write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"">"& vbCrLf
Select case s_num
case 1 '热门
InfoSql="select top "&nums&" * from Info order by hits desc,ID desc"
case 2 '新信息
InfoSql="select top "&nums&" * from Info order by AddDate desc,ID desc"
case 3 '大类热门
InfoSql="select top "&nums&" * from Info where Sort1="&S_info&" order by hits desc,ID desc"
case 4 '小类热门
InfoSql="select top "&nums&" * from Info where Sort2="&S_info&" order by hits desc,ID desc"
case 5 '大类
InfoSql="select top "&nums&" * from Info where Sort1="&S_info&" order by AddDate desc,ID desc"
case 6 '小类
InfoSql="select top "&nums&" * from Info where Sort2="&S_info&" order by AddDate desc,ID desc"
Case 7 '推荐
InfoSql="select top "&nums&" * from Info Where Pw_Good=True ORDER BY id DESC"
Case else '其它
InfoSql="select top "&nums&" * from Info order by hits desc"
End Select

Set InfoRs=Conn.Execute(InfoSql)
if InfoRs.eof or InfoRs.bof then
response.write"<tr><td align='center'>没有信息...</td></tr>"
end if
while not Infors.eof
set title=Infors("title")
set id=Infors("id")
response.write "<tr><td width=""8%""align=""right""><img src=""Img/icon.gif"" width=""12"" height=""11"" align=""absmiddle""></td><td width=""92%"">"& vbCrLf
response.write "<a href='ViewInfo.asp?id="&id&"'title='"&title&"'>"

if GetLen(title)>Linenum then
response.write ""&LeftStr(title,Linenum-2)&""
response.write "..."
else
response.write ""&title&""
end if
if Show_date=1 then
response.write "  "
response.write DateTimeFormat(Infors("AddDate"),3)
End if
response.write "</a></td></tr>"
Infors.movenext
wend
Infors.close
set Infors=nothing
response.write "</table>"
End Function
injoo 2004-11-25
  • 打赏
  • 举报
回复
留个E-m 我发个给你!
我的:injoo@163.com
sdts 2004-11-25
  • 打赏
  • 举报
回复
有些错误 把Response.write "<select name=sel2 onchange=sel_chg()>"
---》Response.write "<select name=sel2>"
复制过来的 忘了去掉
sdts 2004-11-25
  • 打赏
  • 举报
回复
本页名sdts.asp
<html>
<body>
<script language=javascript>
function sel1_chg(){
window.location.href='sdts.asp?sl2='+sel1.value
}
</script>
<select name=sel1 onchange=sel_chg()>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
<%
IF Request("sl2") <> "" THEN
Dim conn,rs,sql
set conn.......
set rs.........
sql="select * from 你的表 where 你的条件字段='"&Request("sl2")&"'"
rs.open sql,conn
Response.write "<select name=sel2 onchange=sel_chg()>"
Do while not rs.eof
Response.write "<option value='"&rs("ID")&"'>"&rs("ID")&"</option>"
rs.movenext
Loop
Response.write "</select>"
END IF
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>

以上代码未经试验 可能有错误
syflin 2004-11-25
  • 打赏
  • 举报
回复
你按照 sdts(上帝天使) 的思路来做,不要心急,定下心来肯定能解决的,或者你搜索一下,好像有个阿信的联动还可以
yqh1314 2004-11-25
  • 打赏
  • 举报
回复
好的帮你找找!!!!!!!!!!!!!!!
3851391 2004-11-25
  • 打赏
  • 举报
回复
能不能给完整的实现代码。
谢谢!不够另外开贴
sdts 2004-11-25
  • 打赏
  • 举报
回复
我的方案
现在所在的页面sdts.asp
第一个下拉框onchange时用window.location.href=sdts.asp?canshu1=所选的数值
第二个下拉框读取参数,如果是空的,不显示;不为空的话就按得到的参数数值查询数据库,得到所要的<option>
如果有更多级的可以类推
古侠 2004-11-25
  • 打赏
  • 举报
回复
你搜索"联动"吧,有太多的这方面的程序呢
3851391 2004-11-25
  • 打赏
  • 举报
回复
没人能帮帮忙吗?

28,391

社区成员

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

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