首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

网站左侧列表新闻数量太长,如何缩短为十个

2013-08-01 
网站左侧列表新闻数量太长,怎么缩短为十个%sub dhl()%h2产品系列/h2%Set rs1server.CreateObject(

网站左侧列表新闻数量太长,怎么缩短为十个
<%sub dhl()%>
<h2>产品系列</h2>

<%
Set rs1=server.CreateObject("adodb.recordset")
sql1="Select * From 0791idc_ProductClass where Classid<>3 and ParentPath='0' order by ClassID"
rs1.open sql1,conn,1,1
j=1
do while not rs1.eof
%>
<div class="jjT"><h3><a href="Product.html"><%=rs1("ClassName") %></a></h3></div>
<div class="jjT1">
<%
Dim rs2,sql2,g,count
Set rs2=server.CreateObject("adodb.recordset")
sql2="select * from 0791idc_Product where  ClassID="&rs1("ClassID")
rs2.open sql2,conn,1,1
if rs2.recordcount=0 then
response.write ("&nbsp;&nbsp;暂无分类!")
end if
g=1
count=1
do while not rs2.eof%>
<div class="jj"><a href="ProductShow-<%= rs2("ID") %>.html"><%
response.Write rs2("Title")

%> </a></div>


<% rs2.movenext
count=count+1
 g=g+1
loop
  rs2.close
set rs2=nothing %>
</div>
<% rs1.movenext
 j=j+1
  loop
  rs1.close
set rs1=nothing
 %>
 <%
Set rs1=server.CreateObject("adodb.recordset")
sql1="Select * From 0791idc_ProductClass where Classid=3 and ParentPath='0'"
rs1.open sql1,conn,1,1
j=1
do while not rs1.eof
%>
<div class="jjT"><h2><%=rs1("ClassName") %></h2></div>
<div class="jjT1">
<%

Set rs2=server.CreateObject("adodb.recordset")
sql2="select * from 0791idc_Product where  ClassID="&rs1("ClassID")
rs2.open sql2,conn,1,1
if rs2.recordcount=0 then
response.write ("&nbsp;&nbsp;暂无分类!")
end if
g=1
count=1
do while not rs2.eof%>
<div class="jjj"><a href="ProductShow-<%= rs2("ID") %>.html"><%
response.Write rs2("Title")

%> </a></div>


<% rs2.movenext
count=count+1
 g=g+1
loop
  rs2.close
set rs2=nothing %>
</div>
<% rs1.movenext
 j=j+1
  loop
  rs1.close
set rs1=nothing
 %>
<%end sub%>
<%sub jianjie(id)%>
<%sql="select * from 0791idc_Aboutus where id="&id
set rs=conn.execute(sql)



if not rs.eof then

%>
<a  href="Aboutus-1.html"><%=left(rs("content"),300)%></a>
<%else
response.Write"暂时没有"
end if
rs.close
set rs=nothing
%>
<%end sub%>
<%sub dhll()%>
<h2>产品系列</h2>

<%
Set rs1=server.CreateObject("adodb.recordset")
sql1="Select * From 0791idc_ProductClass where ClassID<>3 and ParentPath='0' order by ClassID"
rs1.open sql1,conn,1,1
j=1
do while not rs1.eof
%>
<div class="jjT"><h3><a href="Product.html"><%=rs1("ClassName") %></a></h3></div>
<div class="jjT1">
<%
Dim rs2,sql2,g,count
Set rs2=server.CreateObject("adodb.recordset")
sql2="select * from 0791idc_Product where ClassID="&rs1("ClassID")
rs2.open sql2,conn,1,1
if rs2.recordcount=0 then
response.write ("&nbsp;&nbsp;暂无分类!")
end if
g=1
count=1
do while not rs2.eof%>
<div class="jj"><a href="ProductShow-<%= rs2("ID") %>.html"><%
response.Write rs2("Title")

%> </a></div>


<% rs2.movenext
count=count+1
 g=g+1
loop
  rs2.close
set rs2=nothing 
%>
</div>
<% rs1.movenext
 j=j+1
  loop
  rs1.close
set rs1=nothing
 %>
  <%
Set rs1=server.CreateObject("adodb.recordset")
sql1="Select * From 0791idc_ProductClass where Classid=3 and ParentPath='0'"
rs1.open sql1,conn,1,1
j=1
do while not rs1.eof
%>
<div class="jjT"><h2><%=rs1("ClassName") %></h2></div>
<div class="jjT1">
<%

Set rs2=server.CreateObject("adodb.recordset")
sql2="select * from 0791idc_Product where  ClassID="&rs1("ClassID")
rs2.open sql2,conn,1,1
if rs2.recordcount=0 then
response.write ("&nbsp;&nbsp;暂无分类!")
end if
g=1
count=1
do while not rs2.eof%>
<div class="jjj"><a href="ProductShow-<%= rs2("ID") %>.html"><%
response.Write rs2("Title")

%> </a></div>


<% rs2.movenext
count=count+1
 g=g+1
loop
  rs2.close
set rs2=nothing %>
</div>
<% rs1.movenext


 j=j+1
  loop
  rs1.close
set rs1=nothing
 %>
<h2>最新文章</h2>
<%
          
Big


set rs=conn.execute(sql)
if not rs.eof then
do while not rs.eof
title=len(rs("Title"))
If ISHTML = 1 Then
AutoLink = ""&NewName&""&Separated&""&rs("ID")&"."&HTMLName&""
Else
AutoLink = "shownews.asp?ID="&rs("ID")&""
End If
if Title>16 then
%>


<li>·<a href="<%=AutoLink%>"><%=left(rs("Title"),16)%>...</a></li>
<%else%>
<li>·<a href="<%=AutoLink%>"><%=rs("Title")%></a></li>
<%end if%>
<%
rs.movenext
loop
else
response.Write"暂时没有"
end if
rs.close
set rs=nothing
%>
<%end sub%>


<%sub product(num)%>
<%
sql="select top "&num&" * from 0791idc_Product where  FirstPage=true  order by UpdateTime asc"

set rs=conn.execute(sql)
if not rs.eof then
do while not rs.eof
%>

<div class="tt"><h3><a href="ProductShow-<%= rs("ID") %>.html"><img src="<%=rs("DefaultPicUrl")%>" width="165px" alt="网站左侧列表新闻数量太长,如何缩短为十个"title")%>" height="160px" border="0"title="<%=rs("title")%>" /></a></h3><p align="center" style=" height:20px"><a href="ProductShow-<%= rs("ID") %>.html"><%=rs("title")%></a></p></div>

<%
rs.movenext
loop
else
response.Write"暂时没有"
end if
rs.close
set rs=nothing
%>
<%end sub%>

<%sub hangye(BigClassName,num)%>
<%
sql="select top "&num&" * from 0791idc_news where BigClassName='"&BigClassName&"'order by addDate desc"
set rs=conn.execute(sql)
if not rs.eof then
do while not rs.eof
title=len(rs("Title"))
If ISHTML = 1 Then
AutoLink = ""&NewName&""&Separated&""&rs("ID")&"."&HTMLName&""
Else
AutoLink = "shownews.asp?ID="&rs("ID")&""
End If
if Title>16 then

%>
<div class="list"><span><%=year(rs("AddDate"))%>-<%=month(rs("AddDate"))%>-<%=day(rs("AddDate"))%></span>·<a href="<%=AutoLink%>"><%=left(rs("Title"),16)%>...</a></div>
<%else%>
<div class="list"><span><%=year(rs("AddDate"))%>-<%=month(rs("AddDate"))%>-<%=day(rs("AddDate"))%></span>·<a href="<%=AutoLink%>"><%=rs("Title")%></a></div>


<%end if%>
<%
rs.movenext
loop
else
response.Write"暂时没有"
end if
rs.close
set rs=nothing
%>
<%end sub%>

<%function fll()%>

<div id="idPicShow" class="container">
  <ul id="idNum">
  </ul>
</div>
<div id="idPicText"></div>
<div id="idPicList"></div>

<script>
var rvt = new RevealTrans("idPicShow");

//添加变换对象
<%
set rs1=conn.execute("select top 5  * from 0791idc_news where BigClassName='发货现场' order by addDate desc")
if not rs1.eof or not rs1.Bof then
If ISHTML = 1 Then
AutoLink = ""&NewName&""&Separated&""&rs1("ID")&"."&HTMLName&""
Else
AutoLink = "shownews.asp?ID="&rs1("ID")&""
End If
%>
<%
do while not rs1.eof
%>
rvt.Add('<%=rs1("FirstImageName")%>', '', '<%=AutoLink%>');
<%
rs1.movenext
loop
else
%>
rvt.Add('images/logo.gif', '', '');
<%
end if
rs1.close
set rs1=nothing
%>
var oList = $("idPicList"), oText = $("idPicText"), arrImg = [];

var oNum = $("idNum"), arrNum = [];

//设置图片列表
Each(rvt.List, function(list, i){
//图片式
var img = document.createElement("img");
img.src = list["img"]; img.alt = list["text"];
arrImg[i] = img;
oList.appendChild(img);
//按钮式
var li = document.createElement("li");
li.innerHTML = i + 1;
arrNum[i] = li;
oNum.appendChild(li);
//事件设置
img.onmouseover = li.onmouseover = function(){ rvt.Auto = false; rvt.Index = i; rvt.Start(); };
img.onmouseout = li.onmouseout = function(){ rvt.Auto = true; rvt.Start(); };
});

//设置图片列表样式 文本显示区域
rvt.onShow = function(){
var i = this.Index, list = this.List[i];
//图片式
Each(arrImg, function(o){ o.className = ""; }); arrImg[i].className = "on";
//按钮式
Each(arrNum, function(o){ o.className = ""; }); arrNum[i].className = "on";
//文本区域
oText.innerHTML = !!list.url ? "<a href='" + list.url + "' target='_blank'>" + list.text + "</a>" : list.text;


}

//文本显示区域
oText.onmouseover = function(){ rvt.Auto = false; rvt.Stop(); };
oText.onmouseout = function(){ rvt.Auto = true; rvt.Start(); };

rvt.Start();

</script>
<%end function%>
[解决办法]

引用:
Quote: 引用:

查询的时候限制一下   select  top 10  *  from 新闻表  where ......

能说的详细些吗,小白不会。或者帮忙直接改出来。是想缩短新闻数量,左侧列表列出了所有的新闻,想只列出十个。谢谢

这么说吧 你不是有 sql="select top "&num&" * from 0791idc_news where BigClassName='"&BigClassName&"'order by addDate desc"
你只需要改成sql="select top 10 * from 0791idc_news where BigClassName='"&BigClassName&"'order by addDate desc"
其他的没有 top 10 的  只需要在select 后面加上  top 10 

热点排行