ASP advanced article online Management Update (vii)

Source: Internet
Author: User
Tags date define count empty query microsoft frontpage
Online ASP Advanced article online Management Update--Homepage and search

Author: Beach Boy

After the addition of the article, save, display, so now it's time to talk about the management of the display of the main page, that is, to display the title of all articles connected to facilitate the viewer to find articles, it should have the function: Display all the article title connection, add date, browse times and other information, but also must provide paging function, Otherwise, the title of so many articles in a page are displayed, it will be very time-consuming and inconvenient to browse, in addition because this program here combined with the article column search function, so here will also be introduced.

The following is a detailed introduction to the main page of the index.asp of these functions of the implementation process and its specific functions:

"Establish a database connection
<!--#include file= "conn.asp"-->

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>asp Special Section </title>
<meta name= "generator" content= "Microsoft FrontPage 3.0" >
<link rel= "stylesheet" type= "Text/css" href= "Style.css" >
<script language= "JavaScript" >
function popwin2 (path)
{window.open (Path, "", "Height=450,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no, Location=no ");
}
</script>
<%

"Define the maximum article title per page maxperpage, you can modify the number here to achieve your best display effect
Const MAXPERPAGE=18
Dim totalput
Dim currentpage
Dim totalpages
Dim i,j

"If the returned page information is empty, that is, if you enter index.asp directly, then use the first page of the pages defined here
If not IsEmpty (Request ("page") Then
Currentpage=cint (Request ("page")
Else
Currentpage=1
End If
Dim sql
Dim rs
Dim Rstype
Dim typesql
Dim typeid,typename

"If the returned column information is empty, then use the column defined here, where the third column is specified
If not IsEmpty (Request ("typeID")) Then
Typeid=request ("typeID")
Else
Typeid=3
End If

"By returning the column typeid number, open the database to display the specified column, and give the value to typename
Set Rstype=server.createobject ("Adodb.recordset")
Typesql= "SELECT * from type where typeid=" &cstr (typeid)
Rstype.open typesql,conn,1,1
Typename=rstype ("type")
Rstype.close
%>

<body>
<div align= "center" ><center>

<table border= "0" width= "0" cellpadding= "0" >
<tr>
&LT;TD width= "100%" style= Border-left:thin dotted rgb (0,128,0); Border-right:thin dotted rgb (0,128,0) "><p align=" center "><br>

"Display column information, when you click on any of the columns, in the TypeName position will show the relevant information, there is no use of automatic column display mode is considered the display of the page, and the use of manually added mode, to use automatic mode, write it yourself: I believe you learn to now, I can't even make this up!
Dynamic Network ASP Skills >><font color= "#FF0000" ><%response.write "" &typename& ""%></font><br >
<a href= "index.asp?typeid=1" >asp faq</a>|<a href= "index.asp?typeid=2" >ASP components </a> |<a href = "index.asp?typeid=3" >asp Digest </a>|<a href= "index.asp?typeid=4" >asp instance </a>|<a href= " Index.asp?typeid=5 ">asp Security </a> </p>
<div align= "center" >

"Open the specified recordset article and sort by the date of the article, where there are two conditions, one is to use like to query the database and display the relevant article title, as well as to display the specified column by the returned typeID article
<%
Sql= "SELECT * from article where title like '%" &request ("Txtitle") & "% ' and typeid=" +cstr (typeid) + "ORDER by Date D Esc
Set rs= Server.CreateObject ("ADODB.") Recordset ")
Rs.Open sql,conn,1,1

"If the results of the query database point to the beginning or end of the recordset, there are no related articles in the database
If rs.eof and Rs.bof then
Response.Write "<p align= ' center ' > did not find any articles </p>"
Else
"If there is content in the database, get the number of articles in the database
Totalput=rs.recordcount
"If page parameter currentpage is less than 1, specify 1
If Currentpage<1 Then
Currentpage=1
End If
"Use the total number of articles and the maximum article count per page to count the pages of the score page
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 the page is 1 pages or the number of pages minus 1 times the maximum number of articles is less than the total number of articles, then use the already done function showpage in the Showcontent subroutine is the display of the title section of the article above and below display the paging program
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
The Define Bookmark
Dim bookmark
Bookmark=rs.bookmark
ShowPage totalput,maxperpage, "index.asp"



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.