indexx.asp

来自「旅游管理系统 用ASP+SQL 2」· ASP 代码 · 共 195 行

ASP
195
字号
<!--#include file="conn.asp"-->
<!--#include file="const.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")
   	if trim(request("Nclassid"))<>"" then
		Nclassid=trim(request("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
%>

<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="760" id="AutoNumber3">
<tr>
<td><!--#include file="head.htm"-->
</td>
</tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="760" id="AutoNumber4">
<tr>
<td width="150" valign="top" bgcolor="#00BAF2">
<!--#include file="left.htm"-->
</td>
<td width="610" valign="top" bgcolor="#FFFFFF">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber6">
  <tr>
    <td width="100%" bgcolor="#FFFFFF">
	<table border="0" width="100%" cellspacing="3" cellpadding="3" style="border-collapse: collapse" id="table2">
		<tr>
			<td><font color="#000F6C"><a href="index.asp"><u><%=classname%></u></a>…<%if Nclassid="" then%>全部文章<%else%><font color="#ff0000"><a href="indexx.asp?classid=<%=classid%>&Nclassid=<%=Nclassid%>"><u><%=Nclassname%></u></a><%end if%></font></font>&nbsp;</td>
		</tr>
	</table>
	</td>
  </tr>
  <tr>
    <td width="100%" background="pic/line.gif"><img border="0" src="pic/line.gif"></td>
  </tr>
	<tr>
    <td width="100%" bgcolor="#FFFFFF">
    
    
                <div align="center">
    
    
                <table border="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="table1">
                  <tr>
                    <td width="100%"> </td>
                  </tr>
                  <tr>
                    <td width="100%">
                    
<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,"indexx.asp" 
       	else 
       if (currentPage-1)*MaxPerPage<totalPut then 
       rs.move  (currentPage-1)*MaxPerPage 
      showContent 
      showpage totalput,MaxPerPage,"indexx.asp" 
       else 
	   currentPage=1 
       showContent 
       showpage totalput,MaxPerPage,"indexx.asp" 
	  end if 
	end if 
 rs.close 
end if 
	         
sub showContent 
       	dim i 
	   	i=0 
	do while not rs.eof
%>
·&nbsp;<a href="list.asp?id=<%=rs("articleid")%>"><font color=000000><u><%=rs("title")%></u></font></a>
<br>
<% 
	i=i+1
	if i>=MaxPerPage then exit do
	rs.movenext 
	loop 
end sub
%> 
</font> 

</td>
                  </tr>
                  <tr>
                    <td width="100%"> </td>
                  </tr>
                	<tr>
                    <td width="100%" align="center">
                    
<%
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>&nbsp;"

  	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>篇文章/页 "
%>
<%     
end function

   	set rs=nothing   
	conn.close
	set conn=nothing
%>   

                    </td>
                  </tr>
                </table>
</td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#FFFFFF"> </td>
  </tr>
</table>
</td>
</tr>
</table>

<!--#include file="foot.htm"-->
</center>

⌨️ 快捷键说明

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