Results 1 to 3 of 3

Thread: poll(vote) creating help (php)

  1. #1
    Join Date
    Nov 2004
    Posts
    19

    Default poll(vote) creating help (php)

    Can someone create poll like eurosong contex.



    name of song [1] [2] [3] [4] [5] [6]-------radio butons
    name of song2 [1] [2] [3] [4] [5] [6]
    .
    .
    .
    .
    .



    [submit]


    and results in graph mode?

    Anyone have script?
    -Is that possible?

  2. #2
    Join Date
    Nov 2004
    Location
    NYS
    Posts
    29

    Default

    Well,
    as with most php programs, I would start out writing the html first.

    Song1
    <form action=ur script method=post name=song1>
    <input type=hidden name=f_type value=song1>
    <input type=radio name=hott>Its a hottie~!
    <input type=radio name=good>Good
    <input type=radio name=average>Average
    <input type=radio name=poor>Poor
    <input type=radio name=die>Deserves to die
    </form>

    Song2
    <form action=ur script method=post name=song2>
    <input type=hidden name=f_type value=song2>
    <input type=radio name=choice value=hott>Its a hottie~!
    <input type=radio name=choice value=good>Good
    <input type=radio name=choice value=average>Average
    <input type=radio name=choice value=poor>Poor
    <input type=radio name=choice value=die>Deserves to die
    </form>

    watch my html be wrong :-)

    then I'd do a simple php parsing script and send the results to a display script with a cookie, and expire it when it gets there. This won't do a database and log the results, but then you would have to use fwrite and fscanf, I'm experimenting with those right now. This might help to get you started though.

    <?php
    switch($_post[f_type])
    {
    case song1:
    setcookie(song1,'$_POST[choice],3600);
    header("your display script")
    break;
    case song2:
    setcookie(song2,'$_POST[choice],3600);
    header("your display script")
    break;
    }
    ?>
    <html><body></body></html>

    and the display script would be simple enough

    <?php
    ifisset($_COOKIE[song1]){
    echo 'Song1 was voted as being' . $_Cookie[song1];
    setcookie("song1", "", mktime(12,0,0,1, 1, 1990));
    }else{
    ifisset($_COOKIE[song1]){
    echo 'Song1 was voted as being' . $_Cookie[song1];
    setcookie("song2", "", mktime(12,0,0,1, 1, 1990));
    }}

    you could always change the echo's to fwrites, set up a more complicated parsing script with delimiter and line breaks, but I'm having issues where scanf finds my seperator, then appends like i want, but apends OVER the \n, thus overwriting my next line. If you can over come that then go for that approach. GL

  3. #3
    Join Date
    Nov 2004
    Posts
    19

    Default -

    Thank you Black 4C6F747573, that was nice how to :)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •