Professor Chris Sandvig MBA 597 - Introduction to Web Development Management Spring 2005

Last updated: 5/31/2005 1:43:40 PM

<% if printFile < " " then response.write("
") end if %>

Assignment 8 -- Building interactive, data-base driven web pages

In this assignment you will construct the front-end of a on-line bookstore. This assignment combines many of the tools you have learned this quarter. It does not cover any new material.

Bookstore Home Page (default.asp). -- Create a new folder named BookStore for all of your bookstore asp files. Download the book database, put it into your database folder and create a database connect include file that points to it.

The home page should have a header that includes a store name (your choice), logo (you design), shopping cart and account icons. The body of the page will contain a search box, browse menu, and three randomly selected books from the database. You should also create a standard footer. Somewhere on your page include a link called "About this site." For page design ideas see Amazon.com, Wal-Mart.com, bn.com, Crutchfield.com and other on-line stores.

We are not going to worry about making custom icons yet, although you may do so later as a site enhancement. For now, find icons on the internet that you like and use them. Give credit to the originating site in your "about this site" page. You can use the icons from the sample site, which came from Amazon.

The body of the page you should display three randomly selected books from the database. 

To randomly select books, we will generate a random number between 1 and 13. The first book we display will have an ID corresponding to the random number. The second book displayed will correspond to the book ID equal to the random number +1. The third book displayed will correspond to the book ID equal to the random number +2. To generate the random number, use the following code. Use a SQL query to retrieve the relevant information from the database.

Dim iBookID
randomize
iBookID = int (13* rnd(1)) +1

Use Access to write a single SQL statement that retrieves all three books (it will use OR statements).

The book images are located on Yorktown and use the following naming convention is: 
 
http://yorktown.cbe.wwu.edu/sandvig/bookstore/ images/BookISBN.01.ImageSize.jpg

Where BookISBN is the ISBN of the book and ImageSize is the desired image size.  The image sizes are named as follows (naming convention is borrowed from Amazon.com):

Size Extension
Thumbnail (69x97 pixels) .01.20TLZZZZ.gif
Medium (95x140 pixels) .01.MZZZZZZZ.jpg
Large (323 x 475 pixels) .01.LZZZZZZZ.jpg

For example the code to print a thumbnail image is:

<img height="97" width="69" hspace="7" vspace="3" src="http://yorktown.cbe.wwu.edu/sandvig/bookstore/images/<% =objRS("ISBN")%>.01.20TLZZZZ.gif" align="left" border="0">

The book descriptions can be quite long. To trim the description to a consistent length use the VBScript string function Left(string, number) where string is the full description and number is the number of characters you want it trimmed down to. For example, to trim the description to 300 characters:

        <% response.write Left(objRS("description"),300) %>

Search Box: Both the search box and the Browse menu should call a page named search_response.asp. The search box passes the user's search string to the search_response.asp page in a variable named strQuery. Name your submit button 'action' and set its value to 'search.'

Browse Menu:  The browse menu is dynamically generated, displaying only the book categories that are currently in the database. The line of SQL you need to dynamically generate the book categories for the browse menu is:

strSQL= "SELECT DISTINCT book_category.Category FROM book_category;" 

This retrieves only one instance of each book category type. 

The hyperlinks in the browse menu need to contain two parameters. The first is the name of the category that the user clicked (ASP, database, etc.) and the second is "action=browse."

Server-side Includes -- Once you get everything working on the home page (default.asp) paste the page elements that will be used on other pages into server side includes. This includes the header, footer, and search/browse menu.

Product page:  This page displays book details, such as the title, authors, ISBN, price and full description. Use default.asp as a template for this page. You will find that most of the code is reusable.

Use the medium sized image to display the book.. The image should be hyperlinked to the large image. To calculate a discount and print in currency format: 

<% response.write FormatCurrency(.8* objRS("price")) %>

We will want to list authors in many places on the bookstore site so the code for listing them is encapsulated within a subroutines contained in a server-side include. We include the SSI on each page that list authors (the SSI should only be called one time per page and can be anywhere on the page). Here is the code for listing authors (view source). Include it on your page as:

 <!--#include file="ListAuthors.asp"-->

The include file contains a subroutine named subListAuthors(). When you want to list the authors for a book call the subroutine and pass it the ISBN value of the book (note: the subroutine has its own response.write statement and should not be called within another one). The syntax for calling the list authors subroutine is:

subListAuthors ISBN 

Search_response page: Use one page for displaying the results of both search and browse. I suggest that you do browse first, since it is easier. Once you have browse working properly, modify the page to accommodate searches.  Again, I suggest using default.asp as a template since the code is similar.

The page needs to know if it is processing a search or a browse. We will tell it by passing a variable named "action" that has one of two values: search or browse (you can see how this is done in the sample bookstore). Use an IF THEN statement to check for search or browse and use the appropriate SQL statement.

Other than different SQL statements for search and browse, the code for displaying the books is identical for both search and browse.

Search should search the fields title, description, category and Lname.  The SQL strong for a search is: 

strSQL = "SELECT DISTINCTROW book_description.title, book_description.description, book_description.ISBN "&_

"FROM book_authors INNER JOIN (book_category INNER JOIN book_description ON book_category.ISBN = book_description.ISBN) ON book_authors.isbn = book_category.ISBN "&_

"WHERE (((book_authors.Lname) Like '%"&search_string&"%') OR ((book_category.Category) Like '%"&search_string&"%') OR ([book_description]![title] Like '%"&search_string&"%') OR ((book_description.description) Like '%"&search_string&"%'));"

You should tell the user how many books you are displaying. Use the command objRS.RecordCount to find out how many records your SQL query returned. This command requires a scrollable cursor (rather than the usual forward only cursor). Modify your open statement by adding a ", 1" after objConn:

objRS.Open strSQL, objConn, 1

About this Site page: Add a link off your default.asp page that describes the features of your site (so that potential employers don't miss anything). You can copy the content from the "About this demonstration site" from the sample bookstore and modify it.

 


Submitting your assignment via email:

  1. The subject line of your email should read "MBA597 Ax YourName" where x is the assignment number.

  2. Send to .

  3. cc a copy to yourself (as a time-stamped receipt of your submission).
     
    Please check your URLs for accuracy since incorrect addresses will not be graded.