Related articles:
ADO Database connections in FP>
Passing a parameter>
This write up assumes you know
how to create a database
connection in FP2000 to Access
what it means to pass a
parameter to an ASP page
how to use the Database Results
Wizard
If not, please read the
tutorials on this site,
particularly the ASP Wizard
article. Also note, I did not
write “click-by-click”
instructions because I am using
the Japanese version of FP2000
and I don’t know what the
dialogs say exactly in English.
Plus, I’m lazy.
As a prerequisite, I have to
assume you already have a
database of products and a way
of displaying them collectively
with hyperlinks that drill down
to individual product write up
pages. In this example, we will
showcase the product on one of
those pages and include
user-reviews on the same page.
Sorting by date and other
trivial issues such as handling
star gifs, etc. were left out
intentionally.
We will use the analogy for a
virtual bookstore like Amazon.
Preliminary steps:
1. Create a database called
Products (which I assume you
have something
similar).
2. Create a table called Books
that contains information on
your books.
(book_ID, title, author,
editor_review, rating) (Again,
you probably have this in some
form or another.)
3. Create a second table called
Reviews (inside the same
database)
containing at least these fields
(book_ID, review_ID, reviewer,
review,
rating)
4. Import this database into
your web site.
At this point, you should have a
database called “Products”
containing two tables (Books and
Reviews). Books should have
fields at least for an ID,
title, an editor’s review, and a
numeric rating from 0 to 5.
“Reviews” should have fields for
at least an ID, the
corresponding book_ID, reviewer,
review, and a numeric rating
from 0 to 5. For obvious
reasons, make the review fields
in Access “memo” fields. In
summary, you have two tables
linked by the book_ID field in a
one-to-many relation.
Catalog.asp
1. Insert a database results
wizard to display all the books
(or filter as
necessary) in your Books table.
Any format will do but you don’t
need this to be a form region so
delete the form if your option
generates one. On my site, I
formatted the output (step 5 of
the DRW) with the “list ? 1
field per item” option.
2. Create a new page and name it
Showcase.asp. We’ll use this
next.
3. Create a hyperlink from the
Title field of the “Book”
database results
to the Showcase.asp page and
pass the book_ID as the
parameter. Your hypertext link
should say something similar to
ShowCaseBook.asp?<%fp_FieldVal(“book_ID”)%>.
At this point, if you previewed
this page on your server, all
books resulting from Step 1
should appear with the Title
shown as a hyperlink. Clicking
on that should open the
Showcase.asp page (blank yet)
and pass the book_Id as a
parameter.
Showcase.asp
1. Insert the DRW results with a
query of
SELECT from Books WHERE book_ID
= ::book_ID::
2. Format as necessary but make
sure you include the book_ID
field in step
3 of the DRW. You can delete
this entirely from the page if
you wish but you need Frontpage
to include it in its generated
code to so that we can pass it
as a parameter to a hyperlink.
3. On the same page, below the
first results area produced in
Step 1,
insert another DRW results page
this time with a query of SELECT
from Reviews WHERE book_ID = ::book_ID::
4. Format as necessary.
5. At this point, you should
have two database regions.
Insert cursor
before the end of the first one
and hit return.
6. Insert text such as “Add my
review” and create a hyperlink
to
SubmitReview.asp?<%fp_FieldVal(“book_ID”)%>.
(You haven’t made this page
yet.)
At this point, if you had any
reviews for this book (the one
that was clicked on in
Catalog.asp) they would appear
in the second database region.
You can format this to appear
below a gif or simple horizontal
line. Unfortunately, if you are
following this step by step,
there are no records to display
yet. We’ll get there next.
SubmitReview.asp
1. Create a new page and save it
as SubmitReview.asp.
2. I wanted to give my reviewers
the ability to see what they are
reviewing
so I inserted a database results
region on the query of
SELECT * FROM Books Where (book_ID
= ::book_ID::)
In any event, you want to get
the book_ID field from the Books
table onto this form so we can
use it when we INSERT the review
to the Reviews table.
3. I choose to output the
book_ID, title, and review
fields from the Books
table and included the book_Id
as a hidden field. Then I
deleted the <<book_ID>> form on
my page.
4. At this point, you should
have a field within which there
are text
fields for every pertinent field
of the book you want reviewed.
5. Insert your cursor above the
default form buttons and insert
text form
controls for the Review table
fields (reviewer, rating number
of 0 to 5, email address etc.).
Insert a scrolling text form
control for the reviews field
(memo in the database).
6. In the form property dialog,
choose to send to other, then
click Options
and type Insert_Review.asp (we
haven’t made this yet) in the
Actions box. At this point, you
have created a form to submit
the review. We will now make the
handler using the wizard.
Insert_Review.asp
1. Create a new page and save it
as Insert_Review.asp.
2. Insert a database results
region with a custom query (step
2 of the DRW)
3. All the fields entered in the
SubmitReview.asp form are at our
disposal
because they were passed as
parameters to this page. Thus,
you execute a simple INSERT INTO
query like: INSERT INTO Reviews
(book_ID, review, reviewer,
rating, Email,
DateSubmitted) VALUES (::book_ID::,
'::review::', '::reviewer::',
::rating::, '::Email::', #::DateSubmitted::#)
4. At this point, you are done
with the basic functionality. I
am not a
good writer and apologize if
these instructions don’t go into
enough detail. I’ll try to make
up for it by participating in
the user forum.
|