⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.asp

📁 动网文章3.4修改内容 1. 修正以html方式添加文章表格出错的问题 2. 增加单独打印页面 3. 首页调用1.2版  31. 增加设置是否显示文章专题连接
💻 ASP
字号:
<!--#include file="conn.asp"-->
<!--#include file="const.asp"-->
<!--#include file="inc_menu.asp"-->
<%
	dim rs,sql
	dim classid, classname, nclassid, Nclassname
   	dim totalPut   
   	dim CurrentPage, TotalPages
   	if request("classid")<>"" then
		classid=request("classid")
   	else
		classid=0
   	end if
   	if not isempty(request("page")) then
      		currentPage=cint(request("page"))
   	else
      		currentPage=1
   	end if
  	set rs = server.createobject("adodb.recordset")
 	'set rs1=server.createobject("adodb.recordset")
   	if trim(request.querystring("nclassid"))<>"" then
		nclassid=int(request.querystring("nclassid"))
  		sql="select * from ANclass where NclassID="&cstr(nclassid)
 		rs.open sql,conn,1,1
 		if not rs.eof then
			Nclassname=rs("Nclass")
 		end if
		rs.close
   	else
		Nclassid=0
		Nclassname="全部文章"
   	end if
  	sql="select * from Aclass where classID="&cstr(classid)
 	rs.open sql,conn,1,1
 	if not rs.eof then
		classname=rs("class")
 	end if
	rs.close
%>
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<meta name="keywords" content="动网先锋,http://www.aspsky.net">
<LINK href="style.css" rel=stylesheet>
<title><%=classname%>|<%=hosturl%></title>
</head>

<body>
<!--#include file="head.inc" -->
      <TABLE class="border" cellSpacing=0 cellPadding=4 width="95%" border=0 align=center>
        <TR>
          <TD class="title">
<%
	sql="select class,classid from Aclass"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
		response.write "还没有任何栏目"
	else
	do while not rs.eof
%>|&nbsp;&nbsp;<a href="default.asp?classid=<%=rs("classid")%>"><%if cint(rs("classid"))=cint(classid) then%><font color=red><%=rs("class")%></font><%else%><%=rs("class")%><%end if%></a>&nbsp;&nbsp;|&nbsp;&nbsp;  
<%  
	rs.movenext  
	loop  
	end if  
	rs.close  
%>  
	</TD></TR>
        <TR>
          <TD class="title2">
|&nbsp;&nbsp;<%=classname%>>><%if Nclassid="" then%>全部文章<%else%><%=Nclassname%><%end if%>
	</TD></TR>
      </table>
<br>
<div align="center">                                           
  <center>                                           
  <table border="0" width=95% align=center cellspacing="0" cellpadding="1" >
    <tr>  
      <td valign="top" width="25%"> 
        <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 align=center>
  <TBODY>
  <TR>
    <TD>
      <TABLE class="border" cellSpacing=0 cellPadding=4 width="100%" border=0>
        <TR>
          <TD class="title"><b>近期热门文章
	</TD></TR>
        <TR>
          <TD class="tdbg">
<font style=line-height:150%> 
<%

function gotTopic(str,strlen)
	dim l,t,c, i
	l=len(str)
	t=0
	for i=1 to l
	c=Abs(Asc(Mid(str,i,1)))
	if c>255 then
	t=t+2
	else
	t=t+1
	end if
	if t>=strlen then
	gotTopic=left(str,i)&"..."
	exit for
	else
	gotTopic=str&" "
	end if
	next
end function

if nclassid=0 then hotkind=1
select case hotkind
	case "1" sql="SELECT top 10 * FROM article where DateDiff('d',dateandtime,date())<="&DateNum&" order by hits desc,title" 
	case "2" sql="SELECT top 10 * FROM article where DateDiff('d',dateandtime,date())<="&DateNum&" and Nclassid="& nclassid &" order by hits desc,title"
end select
	rs.open sql,conn,1,1 
	if rs.bof and rs.eof then 
		response.write "近期无更新文章" 
	else 
	do while not rs.eof   
%>     
<a href="list.asp?id=<%=rs("articleid")%>" title="<%=rs("title")%>" target=_top><%=gottopic(rs("title"),25)%></a>[<font color=red><%=rs("hits")%></font>]<br>    
<%  rs.movenext     
	loop
	end if  
	rs.close   
%>    
</font> 
	</TD></TR>
      </table>
    </td>
  </tr>
  </tbody>
</table>
      </td> 
      <td valign="top" width="3%">&nbsp;    
      </td> 
      <td width="72%" valign="top">   
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 align=center>
  <TBODY>
  <TR>
    <TD>
      <TABLE class="border" cellSpacing=0 cellPadding=4 width="100%" border=0>
        <TR>
          <TD class="title">|&nbsp;
<%if Nclassid=0 then%><%=Nclassname%>>>
<%
	sql="select * from ANclass where classid="&classid
	rs.open sql,conn,1,1
	do while not rs.eof
		response.write "&nbsp;<a href=index.asp?classid="&classid&"&Nclassid="&rs("Nclassid")&">"&rs("Nclass")&"</a>"
	rs.movenext
	loop
	rs.close
else
%>
<font color=red><%=Nclassname%></font>
<%
	sql="select * from ANclass where Nclassid<>"&Nclassid&" and classid="&classid
	rs.open sql,conn,1,1
	do while not rs.eof
		response.write "&nbsp;<a href=index.asp?classid="&classid&"&Nclassid="&rs("Nclassid")&">"&rs("Nclass")&"</a>"
	rs.movenext
	loop
	rs.close
%>
<%end if%></B>
	</TD></TR>
        <TR>
          <TD class="tdbg">
<font style=line-height:150%> 
<% 
if Nclassid<>0 then
	sql="select * from article where Nclassid="+cstr(Nclassid)+" and classid="+cstr(classid)+"  order by articleid desc" 
elseif classid<>0 then
	sql="select * from article where classid="+cstr(classid)+" order by articleid desc" 
else
	sql="select * from article order by articleid desc"
end if
	rs.open sql,conn,1,1 
  	if rs.eof and rs.bof then 
       		response.write "<p align='center'>没有或没有找到任何文章</p>" 
   	else 
      		totalPut=rs.recordcount 
      		if currentpage<1 then 
          		currentpage=1 
      		end if 

      		if (currentpage-1)*MaxPerPage>totalput then 
	   		if (totalPut mod MaxPerPage)=0 then 
	     			currentpage= totalPut \ MaxPerPage 
	   		else 
	      			currentpage= totalPut \ MaxPerPage + 1 
	   		end if 
      		end if 
       		if currentPage=1 then 
            		showContent 
            		showpage totalput,MaxPerPage,"index.asp" 
       		else 
          		if (currentPage-1)*MaxPerPage<totalPut then 
            			rs.move  (currentPage-1)*MaxPerPage 
            			showContent 
             			showpage totalput,MaxPerPage,"index.asp" 
        		else 
	        		currentPage=1 
           			showContent 
           			showpage totalput,MaxPerPage,"index.asp" 
	      		end if 
	   	end if 
   	rs.close 
   	end if 
	         
sub showContent 
       	dim i 
	   	i=0 
	do while not rs.eof
%><%=i+1%>. 
<a href="list.asp?id=<%=rs("articleid")%>"><%=rs("title")%></a> 
(<%if rs("dateandtime")=date() then%><font color=red><%=month(rs("dateandtime"))%>月<%=day(rs("dateandtime"))%>日</font><%else%><font color='#999999'><%=month(rs("dateandtime"))%>月<%=day(rs("dateandtime"))%>日</font><%end if%>,<font color=green><%=rs("hits")%></font>) 
<br> 
<% 
	i=i+1
	if i>=MaxPerPage then exit do
	rs.movenext 
	loop 
end sub
%> 
</font> 
<!--#include file=query.asp-->
	</TD></TR>
      </table>
    </td>
  </tr>
  </tbody>
</table>
      </td> 
    </tr>                            
  </table>                            
</div>
<%
function showpage(totalnumber,maxperpage,filename)
  	dim n, i
  	if totalnumber mod maxperpage=0 then
     		n= totalnumber \ maxperpage
  	else
     		n= totalnumber \ maxperpage+1
  	end if
  	response.write "<form method=Post action="&filename&"?classid="&request("classid")&"&Nclassid="&request("Nclassid")&">"
  	response.write "<font color='red'>"&Nclassname&"</font>"

  	if CurrentPage<2 then
    		response.write "共"&totalnumber&"篇&nbsp;首页 上一页&nbsp;"
  	else
    		response.write "共"&totalnumber&"篇&nbsp;<a href="&filename&"?page=1&classid="&request("classid")&"&Nclassid="&request("Nclassid")&">首页</a>&nbsp;"
    		response.write "<a href="&filename&"?page="&CurrentPage-1&"&classid="&request("classid")&"&Nclassid="&request("Nclassid")&">上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		response.write "下一页 尾页"
  	else
    		response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&classid="&request("classid")&"&Nclassid="&request("Nclassid")&">"
    		response.write "下一页</a> <a href="&filename&"?page="&n&"&classid="&request("classid")&"&Nclassid="&request("Nclassid")&">尾页</a>"
  	end if
   	response.write "&nbsp;页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
    	response.write "&nbsp;<b>"&maxperpage&"</b>篇文章/页 "
%>
转:<select name='page' size='1' onchange='javascript:submit()' class="smallinput" >   
              <%for i = 1 to n%>   
              <option value='<%=i%>' <%if cint(CurrentPage)=cint(i) then%> selected <%end if%>>第<%=i%>页</option>   
              <%next%>   
            </select>
</form>
<%     
end function

   	set rs=nothing   
	conn.close
	set conn=nothing
%>                            
<!--#include file="foot.inc" -->
</body>                              
</html>                              

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -