Introduction to ASP-an example of online book Management system

Source: Internet
Author: User
Tags include first row

The main functions of this management program are:

1, book list display function, 2, books to place shopping cart, remove shopping cart and empty shopping cart function, 3, purchase book checkout function, 4, new member registration function.

Iindex.asp home. Frame structure. The top frame connects the Top.htm page and the next frame connects the Booklist page.

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上图书管理系统--图书列表</title>
<frameset rows="80,*" cols="*" frameborder="NO" border="0" framespacing="0">
<frame src="top.htm" name="topFrame" scrolling="NO" noresize >
<frame src="booklist.asp" name="mainFrame">
</frameset>
<noframes>
<body>
</body>
</noframes>

Conn.asp the database connection file. You can connect to and open a database as long as the file is included in all pages that are connected to the database.

'创建连接对象
<% set Conn=server.CreateObject("ADODB.Connection")
'连接字符串
strSQL="Driver={Microsoft Access Driver (*.mdb)};DBQ=" &_
server.MapPath("bookshop.mdb")
conn.open(strSQL)
%>

Top.htm book list top page. is just a picture title page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上图书管理系统</title>
<link href="style.css" rel="stylesheet">
<body topmargin="0">
<table width="770" height="124" border="0" cellpadding="-2" cellspacing="-2">
<tr>
<td background="images/bg_booklist.gif">&nbsp;</td>
</tr>
</table>
</body>

Booklist shows all the books in the form of a table.

This page displays all the records in a tabular form. The implementation process is as follows:

1. Use a containing file to create a database connection object;

2, create a Recordset object;

3, create a table, the first line to display the field name;

4, to determine whether the record pointer to the record of the head or tail, if the display of information, if not, then start to extract the current page of each record and page;

5. Read every record of current page by doing while loop statement;

6, through a for loop will be in addition to the current page number of each page to do a hyperlink;

7. Closes the Recordset object and releases all resources it occupies;

8. Close the Connection object and release all the resources it occupies.

<% @LANGUAGE = "VBSCRIPT"%>
<!--use a include file to create a database connection object-->
<!--#include file= "connections/conn.asp"-->
<%
' Create a Recordset object.
Set Rs_booklist=server.createobject ("ADODB. RecordSet ")
Sql= "Select BookID, BookName, bnumber from Db_bookinfo order by Bnumber Desc,bookname"
Rs_booklist.open sql,conn,1,3
%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Book List </title>
<link href= "Style.css" rel= "stylesheet" >
<style type= "Text/css" >
<!--
body,td,th {
font-size:11pt;
Color: #009999;
line-height:1.5;
}
Body {
Background-image:url (images/bg1.jpg);
}
-->
</style>
<body leftmargin= "0" topmargin= "0" >
<div align= "center" >
<!--create a table with the first row to display the field name. -->
<table width= "644" border= "1" bordercolor= "#cccc99" background= "images/bg.jpg" >
<tr>
&LT;TD height= "><div" align= "Center" ><strong> ISBN </strong></div></td>
&LT;TD height= "><div align=" center "><strong> title </strong></div></td>
&LT;TD height= "><div align=" center "><strong> Quantity </strong></div></td>
&LT;TD height= ">&nbsp;</td>"
</tr>
<!--******* paging start ******************-->
<%
' Determine whether the record pointer is outside the head or tail of the record, and if the message is displayed, start by extracting each record and paging the current page.
If rs_booklist. Bof and Rs_booklist. Eof Then
Response.Write "No Data"
Else
' Pagination display
Dim page_size ' This variable is used to store the number of records per page.
Dim page_nonce ' This variable holds the page number for the current page.
Dim page_total ' This variable is used to store the total number of pages.
Page_size=7 ' Sets the first page record number to 7.
Rs_booklist. Pagesize=page_size ' assigns the value in the Page_size variable to the page size (PageSize) property of the Rs_booklist Recordset object.
Page_total=rs_booklist. PageCount ' assigns the page number (PageCount) property of the Rs_booklist Recordset object to the variable page_total.
' The following 5 sentences, is to determine whether the Web page has just opened, if, then assign 1 to variable page_nonce (that is, the current page is the first page),
' If not, the variable value (current page number) obtained from the QueryString collection of the Request object from the HTTP query string is assigned to the variable page_nonce.
If request.querystring ("page_nonce") <> "" Then
Page_nonce=cint (Request.QueryString ("Page_nonce"))
Else
Page_nonce=1
End If
' Assigns the current page number to the Recordset object's property (AbsolutePage) that represents the current record page number.
Rs_booklist. Absolutepage=page_nonce
Dim I
I=page_size
' Reads each record of the current page through the Do While loop statement.
Do as not rs_booklist. Eof and I>0
I=i-1
Response.Write "<tr align= ' center ' >"
Response.Write "<td height= ' >" & Rs_booklist ("BookID") & "</td>"
Response.Write "<td height= ' >" & Rs_booklist ("BookName") & "</td>"
Response.Write "<td height= ' >" & Rs_booklist ("Bnumber") & "</td>"
%>
&LT;TD width= "height=" ><div align= "center" ><a href= "buycar_add.asp?bookid=<%= rs_booklist (" BookID ")%>" target= "Txtframe" ></a></div></td>
<%
' Move the record pointer to the next record.
Rs_booklist. MoveNext
Loop
Response.Write "</table>"
' Start a paging connection.
Response.Write "<p align= ' center ' > Pagination:"
' Make a hyperlink to each page number except the current page number by using the For loop,
For J=1 to Page_total
If j=page_nonce Then
Response.Write J & "&nbsp"
Else
Response.Write "<a href= ' booklist.asp?page_nonce=" & J & "' >" & J & "</a>&nbsp"
End If
Next
End If
Rs_booklist. Close
Set rs_booklist=nothing
Conn.close
Set conn=nothing
%>
</table>
</dir>
</body>

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.