<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      動感首頁更新完成之4 ------ 首頁顯示篇

      [摘要]index.asp '讀入數據庫鏈接! <!--#include file="articleconn.asp"--> <html> <% '每頁最大顯示數為20 const MaxPerPage=20 dim totalPut di...

      index.asp

      '讀入數據庫鏈接!
      <!--#include file="articleconn.asp"-->
      <html>
      <%
      '每頁最大顯示數為20
      const MaxPerPage=20
      dim totalPut
      dim CurrentPage
      dim TotalPages
      dim i,j

      dim typename
      dim keyword
      keyword=trim(request("keyword"))

      if not isempty(request("page")) then
      currentPage=cint(request("page"))
      else
      currentPage=1
      end if

      %>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
      <title>ASP動感在線</title>
      <meta name="GENERATOR" content="Microsoft FrontPage 3.0">
      <link rel="stylesheet" href="../css/style.css">
      </head>
      <body bgcolor="#FFFFFF">
      <table width="90%" cellpadding="0" cellspacing="0" align="center">
      <tr>
      <td colspan="3" height="203">
      <table border="1" width="100%" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0" cellspacing="0" align="center">
      <tr bgcolor="#ACD6FF">
      <td width="100%" height="20">
      <p align="center"><font color="#000000"><b>站 務 公 告</b></font>
      </td>
      </tr>
      <tr>
      <td width="100%" height="152">
      <form method="post" action="index.asp">
      <br>
      <font color="#FF0000"> </font>
      <table border=0 cellpadding=0 cellspacing=0 width="54%" align="center">
      <tr>
      <td valign=center colspan="3" align="right">
      <div align="center">查詢關鍵字<font color="#FF0000"><%=keyword%></font>
      </div>
      </td>
      </tr>
      <tbody>
      <tr>
      <td width="27%" align="right">請輸入搜索字符: </td>

      <td valign=center width="54%" align="center">
      <input class=TextBorder maxlength=25
      name=keyword size=26>
      &nbsp;&nbsp;</td>
      <td valign=buttom width="19%" align="left">
      <input alt=站內搜索 border=0
      name=submit src="/article/UploadPic/200671952024896.gif" type=image>
      </td>
      </tr>
      </tbody>
      </table>
      </form>
      <p align="left"><%
      '打開數據庫內容安ARTICLEID的倒數排列!
      'title like '%"&keyword&"%' 為對搜索字的查找,空者表示全部!
      sql="select * from learning where title like '%"&keyword&"%' order by articleid desc"
      dim sql,rs
      Set rs= Server.CreateObject("ADODB.Recordset")
      rs.open sql,conn,1,1

      '判斷數據庫是否為空!如果為空顯示'還 沒 有 任 何 文 章'

      if rs.eof and rs.bof then
      response.write "<p align='center'> 還 沒 有 任 何 文 章</p>"
      else
      '下面是對文章數,每頁顯示數的判斷!大家可作其它程序的參考!!
      totalPut=rs.recordcount
      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
      showpage totalput,MaxPerPage,"index.asp"
      showContent
      showpage totalput,MaxPerPage,"index.asp"
      else
      if (currentPage-1)*MaxPerPage<totalPut then
      rs.move (currentPage-1)*MaxPerPage
      dim bookmark
      bookmark=rs.bookmark
      showpage totalput,MaxPerPage,"index.asp"
      showContent
      showpage totalput,MaxPerPage,"index.asp"
      else
      currentPage=1
      showpage totalput,MaxPerPage,"index.asp"
      showContent
      showpage totalput,MaxPerPage,"index.asp"
      end if
      end if
      rs.close
      end if

      set rs=nothing
      conn.close
      set conn=nothing


      sub showContent
      dim i
      i=0

      %> </p>

      <table border="0" cellspacing="0" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0" vspace="10" hspace="40" align="center" width="80%">

      '循環輸出數據庫中的數據,一直到結束!

      <tr> <%do while not rs.eof%>
      <tr>

      <td colspan="2"><font color="#000099">○</font> <a '<%rs("xxx")%>就是數據庫要顯示的內容是編寫ASP的關鍵
      '這個動作是對程序的目的,即得出顯示結果!
      href="<%=rs("url")%>" target="_blank"><%=rs("title")%></a>
      <i><font color="#FF0000">(<%=rs("dateandtime")%>)</font></i></td>
      </tr>
      <tr>

      <td width="550" colspan="2"><%=rs("content")%> <br>
      <br>
      </td>
      </tr>
      <% i=i+1
      if i>=MaxPerPage then exit do
      rs.movenext
      loop
      %>
      </table>

      <%
      end sub

      '大家看到的上頁下頁就是從這里得到的.可作其它程序的參考!
      function showpage(totalnumber,maxperpage,filename)
      dim n
      if totalnumber mod maxperpage=0 then
      n= totalnumber \ maxperpage
      else
      n= totalnumber \ maxperpage+1
      end if
      response.write "<form method=Post action="&filename&">"
      response.write "<p align='center' vAlign='bottom'>&gt;&gt;分頁&nbsp;"
      if CurrentPage<2 then
      response.write "<font color='999966'>首頁 上一頁</font>&nbsp;"
      else
      response.write "<a href="&filename&"?page=1&>首頁</a>&nbsp;"
      response.write "<a href="&filename&"?page="&CurrentPage-1&">上一頁</a>&nbsp;"
      end if
      if n-currentpage<1 then
      response.write "<font color='999966'>下一頁 尾頁</font>"
      else
      response.write "<a href="&filename&"?page="&(CurrentPage+1)
      response.write ">下一頁</a> <a href="&filename&"?page="&n&">尾頁</a>"
      end if
      response.write "&nbsp;頁次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>頁 "
      response.write "&nbsp;共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/頁 "
      response.write " &nbsp;轉到:<input class=TextBorder style='TEXT-ALIGN: center' type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">"
      response.write " &nbsp;&nbsp;<input alt=頁面跳轉 name='submit' src='http://www.okasp.com/images/goto.gif' type='image'></span></p></form>"

      end function


      %> </td>
      </tr>
      </table>
      </td>
      </tr>
      </table>
      '版權信息!不作解釋了!
      <p align="center">《<a target="_blank">ASP動感在線</a>》編輯制作</p>
      </body>
      </html>

      大家注意的是兩點:
      1.個位可參照上面的程序舉一反三!
      2.<%=rs("xxx")及顯示你txturl,txttitle等的內容,這是學ASP關鍵所在,這一點如果明白了!學ASP差不多到了一個新的境界!
      (出處:熱點網絡)


      日韩精品一区二区三区高清