Why not have a field called last in the db? You set it equal to true for the last image and then check it for all of the images. If it's true, you just null the next option and the user can't go any farther.

From: Matthew Horn <[EMAIL PROTECTED]>
Subject: [PHP-DB] hotornot functionality
Date: Wed, 28 May 2003 08:55:59 -0400
MIME-Version: 1.0
Received: from pb1.pair.com ([]) by mc1-f1.law16.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Wed, 28 May 2003 05:56:22 -0700
Received: (qmail 87531 invoked by uid 1010); 28 May 2003 12:56:18 -0000
Received: (qmail 87516 invoked from network); 28 May 2003 12:56:17 -0000
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
list-help: <mailto:[EMAIL PROTECTED]>
list-unsubscribe: <mailto:[EMAIL PROTECTED]>
list-post: <mailto:[EMAIL PROTECTED]>
Delivered-To: mailing list [EMAIL PROTECTED]
X-Mailer: Internet Mail Service (5.5.2653.19)
X-OriginalArrivalTime: 28 May 2003 12:56:22.0911 (UTC) FILETIME=[8A78A0F0:01C32518]

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:

1. A picture is served up.
2. User clicks on a radio button scale from 1 to 10 to "rate" the picture.
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 served up.
4. The user can cycle through as many pictures this way as they want.

I have MySQL and PHP to work with.

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 via JavaScript. The form submit updates the database with the rating and then fetches the next row.

The problem that occurred to me as I was putting together a prototype is:

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 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, which should work ok, but the problems come up when they reach the last row.

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.


Matthew J. Horn

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to