I think the best way is to use sessions.
when the user comes to the site or he submits a rating, start a
session and create a variable, in which you store the images' id that
the user rated like
etc.. then use it in your query
mysql_query("select id from images where id not in ($var) order by
rand() limit 1");
this will keep the images the user rated out of your recordset and
gives you a random image from the database
MH> I am toying with the idea of implementing functionality similar to the
hotornot.com site -- for a different purpose, mind you, but the same kind of user
experience. Here's what it does:
MH> 1. A picture is served up.
MH> 2. User clicks on a radio button scale from 1 to 10 to "rate" the picture.
MH> 3. The page refreshes. The rating is re-computed with the user's rating for the
original picture. The original picture becomes that "last rated" pic, and a new one is
MH> 4. The user can cycle through as many pictures this way as they want.
MH> I have MySQL and PHP to work with.
MH> What I am trying to do is figure out the best approach to implementing it.
Specifically, when the user clicks on the radio button, that triggers the form submit
MH> updates the database with the rating and then fetches the next row.
MH> The problem that occurred to me as I was putting together a prototype is:
MH> I don't want the user to get the entire result set of all the images in the
database at once. I really want them to get just the two images (the one they just
rated and the one they are about to
MH> rate). Is there a way to "remember" the last row they selected and then use that
number to fetch the next one on the subsequent request? I can keep recycling hidden
form fields with a number,
MH> which should work ok, but the problems come up when they reach the last row.
MH> Anyway, just looking to see if you folks have some ideas. I would prefer to roll
my own rather than use one of the available "hotornot-style" PHP scripts to do this.
MH> Matthew J. Horn
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php