日期:2011-01-14  浏览次数:20911 次

第二部分:实例

项目结构:
该项目主要由几个ASP文件和一个数据库组成:

book.mdb:存放数据库的内容
index.asp:网站主要的文件,大部分的内容均由它来显示
buy.asp:购物蓝的内容
in.asp:供登录使用
registry.asp:使您成为我们的会员
数据库(book.mdb):
第一个表是Book,用于存储关于书目的一些相关的信息,结构如下:

ID
整型
书的序号

Name
字符
书的名字

Author
字符
作者

Brief
字符
简介

Ifcover
整型
是否首页显示

Price
双精度
价格

Publisher
字符
出版社

Cover
字符
封面的图片的路径

Flag
整型
标志


第二个表是info,用于存储会员的信息,结构如下:

Id
字符
会员登录号

Name
字符
会员姓名

Pwd
字符
登录密码

Email
字符
 
Address
字符
地址

Phone
字符
电话

Post
字符
邮编

Sfz
字符
身份证号码


第三个表是class,用于存储书目的类别,其结构如下:

ID
字符
编号

Name
字符
类别


几个ASP文件的内容:
Index.asp
<!--

分三个TD,最主要的中间的一个,大多数操作都是对中间的一个。

-->

<%@ Language=VBScript %>

<script language=javascript>

function openwindow(num){

window.open ("info.asp?key=" + num,"yu",0,0)

}

</script>

<script language=javascript>

function buy(name){

window.open ("buy.asp?name=" + name ,"yu",0,0)

}

</script>

<script language=javascript>

function viewPage(ipage){

document.Page.txtPage.value=ipage

document.Page.submit()

}

</script>

<HTML>

<HEAD>

<title>网上书店</title>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

</HEAD>

<BODY bgColor=lightcyan>

<P align=center><IMG alt="网上书店"

src="http://edu.cnzz.cn/NewsInfo/file://C:/InetPub/wwwroot/images/title.jpg"><br>

<TABLE align=center border=0 cellPadding=0 cellSpacing=10
width="100%" style="BORDER-BOTTOM-COLOR: red; BORDER-LEFT-COLOR: red;
BORDER-RIGHT-COLOR: red; BORDER-TOP-COLOR: red">

<tr>

<td colspan=3>

<table border=1 width=100% bgcolor=Khaki cellpadding=0 cellspacing=0>

<tr>

<td bgcolor=MediumSeaGreen ><% =year(date()) & "年" & month(date)
& "月" & day(date) & "日" %></td>

<td bgcolor=MediumSeaGreen ><a href="about.htm">关于我们</a></td>

<td bgcolor=MediumSeaGreen ><a href=buy.asp?name=view>查询购物蓝
</a></td>

<%

if session("UserID")<>"" then

Response.Write "<td bgcolor=MediumSeaGreen> 会员:" & session
("UserName") & "</td>"

else

Response.Write "<td bgcolor=MediumSeaGreen>会员:未登录</td>"

end if

if session("sum")="" then session("sum")=0

Response.Write "<td bgcolor=MediumSeaGreen>购货总金额:" & session
("sum") & "</td>"

%>

</tr>

</table>

</td>

</tr>

<TR>

<TD width="15%" valign=top bordercolor=deeppink bgcolor=beige>

<A href=index.asp?ifcover=1><P align=center>

最新书目</a><br>

畅销书目<br>

<hr color=deeppink>

<P></P>

<p align=center>

图书分类<br>

<table border=1 cellspacing=0 cellpadding=0 width=100%>

<% set rs=server.CreateObject("ADODB.recordset")

rs.open "select * from class order by ID","DSN=sqlsales;UID=sa;",3,3

rs.movefirst

do while not rs.eof

Response.Write "<tr><td align=center>"

Response.Write "<A href=index.asp?flag=" & rs("ID") & ">" & rs
("Name") & "</a><br>"

Response.Write "&l