Forums
This topic is locked
rating / voting system help needed!
Posted 06 Sep 2005 12:19:47
1
has voted
06 Sep 2005 12:19:47 billy jones posted:
Does anyone know of a good tutorial / example of an asp function to let users write reviews for resources? Similar to what Amazon use for users to rate their products - space for a few paragraphs of text and a points score (1-5).I am currently using a single resources table (Access 2003 mdb) but am aware that it may require a 1-many relationship (eg one resource has many reviews). I havent worked out multiple tables within dreamweaver yet so any help and pointers will be much appreciated!!
Replies
Replied 06 Sep 2005 15:18:23
06 Sep 2005 15:18:23 Michael Behan replied:
I would do that like this:
2 tables
table1: existing table must have a unique key column, say itemID which is an autonumber
table2: new table has 4 fields. reviewID (unique key, autonumber), itemID, reviewText, score (you may want extra fields for reviewer name etc..)
So when someone clicks a review this button the link is something like this: newReview.asp?itemId=500
newReview.asp is a page with a form that has 3 fields. a hidden field called itemId that is set to Request("itemId" a textarea for the review and a drop down with numbers 1 to 5 for the score. this form inserts a record into table2.
now back on the page that has the item, you also want to show its reviews. do it like this:
2 recordsets
recordset1 : existing recordset gets the item that you want.
recordset2: gets every review for that item like this:
select * from reviewTable WHERE itemID = param1
param 1 is defined like this:
name | default | runtime value
param1 | 0 | recodset1.Fields.Item("itemID".Value
and thats it. you can display the info from recordset2 under the item in a repeat region.
Edited by - mbisme on 06 Sep 2005 15:19:28
2 tables
table1: existing table must have a unique key column, say itemID which is an autonumber
table2: new table has 4 fields. reviewID (unique key, autonumber), itemID, reviewText, score (you may want extra fields for reviewer name etc..)
So when someone clicks a review this button the link is something like this: newReview.asp?itemId=500
newReview.asp is a page with a form that has 3 fields. a hidden field called itemId that is set to Request("itemId" a textarea for the review and a drop down with numbers 1 to 5 for the score. this form inserts a record into table2.
now back on the page that has the item, you also want to show its reviews. do it like this:
2 recordsets
recordset1 : existing recordset gets the item that you want.
recordset2: gets every review for that item like this:
select * from reviewTable WHERE itemID = param1
param 1 is defined like this:
name | default | runtime value
param1 | 0 | recodset1.Fields.Item("itemID".Value
and thats it. you can display the info from recordset2 under the item in a repeat region.
Edited by - mbisme on 06 Sep 2005 15:19:28
Replied 15 Sep 2005 20:15:04
15 Sep 2005 20:15:04 billy jones replied:
Thanks for that it works really well, but how can I enable users to actually add their own reviews?
When I try to do it Dreamweaver says I need an updateable query. Im guessing its becuase im using a one-many database relationship between the tables (one item has many reviews).
How can I get a page to show the item I want, and also allow a new review to be entered?
When I try to do it Dreamweaver says I need an updateable query. Im guessing its becuase im using a one-many database relationship between the tables (one item has many reviews).
How can I get a page to show the item I want, and also allow a new review to be entered?
Replied 16 Sep 2005 12:51:48
16 Sep 2005 12:51:48 Michael Behan replied:
The way I describe in the previous post should do this fine:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>when someone clicks a review this button the link is something like this: newReview.asp?itemId=500
newReview.asp is a page with a form that has 3 fields. a hidden field called itemId that is set to Request("itemId" a textarea for the review and a drop down with numbers 1 to 5 for the score. this form inserts a record into table2.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
So on the page with the resource and it's current reviews there is a link that says something like this "Review this resource!" its link should be newReview.asp?itemId=<pre id=code><font face=courier size=2 id=code><%=Recordset1.Fields.Item("itemId".Value%></font id=code></pre id=code> where recordset1 and itemId are the recordsets/fields described in the other post.
Now on to the page newReview.asp we need:
1. A form called newReview with 3 form fields fields as described already
2. An insert record behaviour set up like this
Connection : whatever conection you currently use
Insert into table: table2
After inserting goto: whatever you want
Get values from: newReview (the name of the form)
Form Elements: if you have given the form fields the same name as the database fields this should be done for you already, otherwise match up the form fields with the database ones.
[table 2 as in previous post]
And that should work fine
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>when someone clicks a review this button the link is something like this: newReview.asp?itemId=500
newReview.asp is a page with a form that has 3 fields. a hidden field called itemId that is set to Request("itemId" a textarea for the review and a drop down with numbers 1 to 5 for the score. this form inserts a record into table2.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
So on the page with the resource and it's current reviews there is a link that says something like this "Review this resource!" its link should be newReview.asp?itemId=<pre id=code><font face=courier size=2 id=code><%=Recordset1.Fields.Item("itemId".Value%></font id=code></pre id=code> where recordset1 and itemId are the recordsets/fields described in the other post.
Now on to the page newReview.asp we need:
1. A form called newReview with 3 form fields fields as described already
2. An insert record behaviour set up like this
Connection : whatever conection you currently use
Insert into table: table2
After inserting goto: whatever you want
Get values from: newReview (the name of the form)
Form Elements: if you have given the form fields the same name as the database fields this should be done for you already, otherwise match up the form fields with the database ones.
[table 2 as in previous post]
And that should work fine
Replied 16 Sep 2005 12:54:26
16 Sep 2005 12:54:26 Michael Behan replied:
If you want it on the same page that shows the item it's exactly the same. everything that is on newReview.asp in the last post just put into that page.
Replied 16 Sep 2005 14:32:27
16 Sep 2005 14:32:27 billy jones replied:
Thanks for your help, but im still getting the "Operation must use an updateable query." in IE.
Would it be possible for me to email you what I have so far?
Would it be possible for me to email you what I have so far?