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?