Re: hotornot functionality

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Uh, why not just do this:

<input type='hidden' name='lastid' value='1930'>

Then on the next page, you can get the id.  Or geez, it's gonna be there
anyway -- after you do the insert/update of your vote, just pass that ID to
the function that displays the page.

function display($x) {
    if (!empty($x['vote'])) {
        db_query("insert into vote (pid,vote) values (".$x['thisid'].",".$x['vote'].")");
    }
    $r = db_query("select * from pictures order by rand() limit 1");
    $row = mysql_fetch_array($r); // sure, do error checking if you want
    beginpage($x['thisid'],$x['vote']);
    votebar($row['pid']);
    echo "<img src='".$row['imgurl']."'>";
    endpage();
}

assuming beginpage is responsible for displaying the last image you voted
on.

Peter

On Wed, 28 May 2003, Matthew Horn wrote:

> 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
>

---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux