Print Page | Close Window

Image rating help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3609
Printed Date: 29 March 2026 at 8:10pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Image rating help
Posted By: Nischint
Subject: Image rating help
Date Posted: 17 June 2003 at 10:15am

I'm building an image rating app and am having some trouble. I have one db, with two tables, "images" and "ratings".

images Fields - imgid, imgtitle, imglink
ratings Fields - rateid, imgid, imgtitle, imgrating, visitorip, ratedate

The image are shown in random order (using ADO), so the sql is:

sql= "select imgid, imgtitle, imglink from images order by imgid desc"
rs.Open sql, cn, 3, adCmdText

Dim intRnd
Randomize Timer
intRnd = (Int(RND * rs.RecordCount))
rs.Move intRnd

The user rates the image, and then submits a form, which brings up another page, with a new random image.

Although this gives me a random image every time, sometimes the images are repeated. Now how do I make sure that a user gets a different random image every time?

In the ratings, the sql inserts the IP of the user who rated the image. Should I use that or cookies? If I use the ip method, how do I interact with the two tables?

Another thing. Once an image is displayed, how do I check the ratings table to find out if the image has been rated before, and what the average rating is, and display that result?



-------------
A better idiot

http://www.jamlikethat.com">Jam Like That



Replies:
Posted By: michael
Date Posted: 17 June 2003 at 10:49am
What database type are you using? If you use SQL Server it does the joing automatically for you so you should be able to use a q like:
select imgid, imgtitle, imgling from images, ratings where ratings.visitorip <> & ncVisIP
If you use access you might have to do an inner join on the ratings table.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Nischint
Date Posted: 17 June 2003 at 11:17am

I am using Access 2000, and i've already made a query that joins all the results:

SELECT images.imgid, images.imgtitle, images.imglink, ratings.rateid, ratings.imgip, ratings.imgrating
FROM images INNER JOIN ratings ON images.imgid = ratings.imgid;


From here, how do I go??



-------------
A better idiot

http://www.jamlikethat.com">Jam Like That



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net