Online "Shop" DIY (2)

Source: Internet
Author: User
Tags date chr dsn visual studio
Part II: Examples

Project structure:
The project consists mainly of several ASP files and a database:

Book.mdb: Storing the contents of a database
Index.asp: The main document of the website, most of the content is displayed by it
Buy.asp: The content of shopping blue
In.asp: For logon use
Registry.asp: Make you a member of our
Database (Book.mdb):
The first table is book, which stores some of the relevant information about the bibliography, structured as follows:

Id
Integral type
The serial number of the book

Name
Character
The name of the book

Author
Character
Author

Brief
Character
Brief introduction

Ifcover
Integral type
Whether home display

Price
Double precision
Price

Publisher
Character
Press

Cover
Character
The path to the picture of the cover

Flag
Integral type
Sign


The second table is info, which is used to store members ' information, structured as follows:

Id
Character
Member Login number

Name
Character
Member name

Pwd
Character
Login Password

Email
Character
 
Address
Character
Address

Phone
Character
Phone

Post
Character
Zip

Sfz
Character
ID number


The third table is class, which is used to store categories of bibliographies, which are structured as follows:

Id
Character
Number

Name
Character
Category


Contents of several ASP files:
Index.asp
<!--

Divided into three TD, the most important one in the middle, most of the operation is to the middle one.

-->

<%@ 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> Online Bookstore </title>

<meta name= "generator" content= "Microsoft Visual Studio 6.0" >

</HEAD>

<body bgcolor=lightcyan>

<p align=center>
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>

&LT;TD colspan=3>

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

<tr>

&LT;TD bgcolor=mediumseagreen ><% =year (Date ()) & "Year" & Month (date)
& "Month" & Day (date) & "Days"%></td>

&LT;TD bgcolor=mediumseagreen ><a href= "about.htm" > About Us </a></td>

&LT;TD bgcolor=mediumseagreen ><a href=buy.asp?name=view> query Shopping Blue
</a></td>

<%

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

Response.Write "&LT;TD bgcolor=mediumseagreen> Member:" & Session
("UserName") & "</td>"

Else

Response.Write "&LT;TD bgcolor=mediumseagreen> Member: not logged in </td>"

End If

If session ("sum") = "" Then session ("Sum") =0

Response.Write "&LT;TD bgcolor=mediumseagreen> Purchase Total amount:" & Session
("Sum") & "</td>"

%>

</tr>

</table>

</td>

</tr>

<TR>

&LT;TD width= "15%" Valign=top bordercolor=deeppink bgcolor=beige>

<a href=index.asp?ifcover=1><p align=center>

Latest Bibliography </a><br>

Best Sellers <br>

&LT;HR color=deeppink>

<P></P>

<p align=center>

Book Classification <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 as not rs.eof

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

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

Response.Write "</td><tr>"

Rs.movenext

Loop

%>

</table>

</p>

</TD>

<td width = "65%" bordercolor=orangered valign=top>

<% if Request.QueryString ("flag") = "" and Session ("flag") = "" or
Request.QueryString ("Ifcover") =1 then%>

<%

Set Rs=server. CreateObject ("ADODB.") Recordset ")

Rs. Open SELECT * FROM book where
Ifcover=1 "," dsn=sqlsales; Uid=sa; ", 3,3

%>

<p align=center style= "Font-size:x-large" ><font

Color=mediumslateblue style= "Font-family:serif" > Latest bibliography </FONT></P>

<% for I=1 to Rs. RecordCount%>

<table border=0 cellpadding=5 cellspacing=5 width= "100%" >

<tr>

&LT;TD colspan=2><font color=red size=5 ><p align=center><%. Fields
("Name")%></p></font></td>

</tr>

<tr>

&LT;TD width= "30% ><a href=" Javascript:openwindow (<% =rs. Fields ("ID")%
>) ">>

</td>

<td><font color=mediumslateblue> ISBN: </font><% =rs. Fields ("ID")%><br>

<font color=mediumslateblue> Author: </font><% =rs. Fields ("Author")%
><br><font

Color=mediumslateblue> Original Price: </font><% =rs. Fields ("Price")%><br><font
Color=mediumslateblue> Current: </font><% =rs. Fields ("Price")%><br><font

Color=mediumslateblue> Publishing house </font><% =rs. Fields ("Publisher")%></td>

</tr>

<tr>

&LT;TD colspan=5> <font

color= #660066 ><% =rs. Fields ("Brief")%>

</FONT>

</td>

</tr>

<tr>

&LT;TD colspan=6><p align=right><a href=buy.asp?name=<% =rs. Fields ("ID")
& "'" & Rs.fields ("Name") & "'" & Rs.fields ("Price")%>> purchase
</A></p></td>

</tr>

</table>


<% Rs. MoveNext

Next

Rs. Close

%>

<% ElseIf request.querystring ("flag") =9999 Then

Response.Write "Shopping Blue"

Else

Set Rs=server. CreateObject ("Adodb.recordset")

If Request.QueryString ("flag") <> "" Then session ("flag")
=request.querystring ("flag")

Rs.Open "select* from book where flag=" & session
("Flag"), "dsn=sqlsales; Uid=sa; ", 3,3

Session ("Pagenum") =rs. PageCount

If Rs. RecordCount <>0 Then

%>

<table border=1 width= "100%" >

<tr>

&LT;TD width=40% align=center> Title </td>

&LT;TD width=15% align=center> Author </td>

&LT;TD width=29% Align=center> Press </td>

&LT;TD width=8% align=center> Price </td>

&LT;TD width=8% align=center> Order </td>

</tr>

<%

Rs. MoveFirst

Session ("Pagecur") =session ("Pagecur" & Request.QueryString ("flag"))

If session ("pagecur") = "" Then

Session ("Pagecur") =1

Rs. Absolutepage=1

Else

if (Request.Form ("txtpage")) = "" Then

' Response.Write session ("Pagecur") & "<BR>"

Rs. AbsolutePage =session ("Pagecur")

Session ("page") =session ("Pagecur")

Else

Rs. AbsolutePage =clng (Request.Form ("Txtpage"))

Session ("page") =clng (Request.Form ("Txtpage"))

' Session (' Page ') =clng (Request.Form ("Txtpage"))

End If

End If

%>

<form action= "index.asp" Method=post name=page>

<% = "<a href=" & Chr (+) & "Javascript:viewpage (1)" & Chr (+) & "> Home
</a> "%>

<%

If session ("Page") = "" Then

Session ("Page") =1

End If

If CLng (Session ("Page")) >1 Then

Session ("Pagecur") =clng ("page")-1

Response.Write "<a href=" & Chr (+) & "Javascript:viewpage (" & Session
("Pagecur") & ")" & Chr (+) & "> Pre-page </a>"

Else

Response.Write "Front Page"

End If

If CLng (Session ("Page")) &LT;CLNG (Session ("Pagenum")) Then

Session ("Pagecur") =CLNG (Session ("Page")) +1

Response.Write "<a href=" & Chr (+) & "Javascript:viewpage (" & Session
("Pagecur") & ")" & Chr (+) & "> Back Page </a>"

Else

Response.Write "Back Page"

End If

Response.Write "<a href=" & Chr (+) & "Javascript:viewpage (" & Session
("Pagenum") & ")" & Chr (+) & "> Last </a>"

%>

<input id=txtpage name=txtpage style= "HEIGHT:22PX; Width:103px "
Value=1>

<input id=submit1 name=cmdpage type=submit value=go style= "background-
Color:peru; Color:greenyellow ">

</form>

<%

I=0

Do but not Rs. EOF and I<rs. PageSize

I=i+1

Response.Write "<tr>"

' Response.Write ' <td> ' & Rs. Fields ("ID") & "</td>"%>

<td><a href= "Javascript:openwindow" (<% =rs. Fields ("ID")%>) "><%
=rs. Fields ("Name")%></a></td>

<% Response.Write "<td>" & Rs. Fields ("Author") & "</td>"

Response.Write "<td>" & Rs. Fields ("Publisher") & "</td>"

Response.Write "<td>" & Rs. Fields ("Price") & "</td>"

Response.Write "<td> Order </td>"

Response.Write "</tr>"

Rs. MoveNext

Loop

Response.Write "</table>"

End If

Rs. Close

End If%>

&LT;TD width= "20%" Valign=top bordercolor=orangered bgcolor=beige>

<form method=post action= "in.asp" Id=login name=login>

<p align=center>

Member Login </p><p align=center> user <input

Id=text1 Name=txtuser size=12>

<br>

Password <input id=text2 name=txtpwd size=12 type=password></p>

<p align=center><input Id=cmdlogon Name=cmdlogon type=submit value=
Into ><input id=cmdreg name=cmdreg Type=button value= Apply
onclick=window.location.href= "Registry.asp" ></form></P>

<%

' Session (' Num_book ') =session ("num")

' If session ("Num_book") <> "then

' Num_book=clng (Session ("Num_book"))

' Response.Write ' <table border=1 width=100%\><tr><td> ISBN </td><td> List
Price </td><td> Quantity </td></tr> "

' For i=0 to Num_book

' Response.Write <tr><td> ' & Session ("Id_" & CStr (Num_book))
& "</td><td>" & Session ("Price_" & CStr (Num_book)) & "</td><td>" &
Session ("Num_" & CStr (Num_book)) & "</td></tr>"

' Next

' Response.Write ' </table> '

' End If

%>

<P> for you to get a more favorable price, please apply to be our member and login here. </P>

<p> Payment Method: The use of the post office or door-to-door method.
</p></TD></TR></TBODY></TABLE></P>

<p Align=center><font size=2 color=blue> This site contains text and pictures copyright Attribution Evou
All, without permission, shall not be transcribed <br> Yevou </font></p>

</BODY>

</HTML>



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.