Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: polls

  1. #1
    Registered User
    Join Date
    Jan 2003
    Location
    CT
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    polls

    i am looking for an ad-free poll script, one such as at http://www.teamareola.com towards the bottom.
    i have tried hotscripts but they have proved unreliable.
    any suggestions plz?

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Registered User
    Join Date
    Jan 2003
    Location
    CT
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i actually just found one that i like:

    PHP Code:
    <?php
    // En: Begin PHP Code / Fr: Debut code PHP
    /******************************************************************************\
    * PHP Poll                                     Version 1.0                     *
    * Copyright 2000 Frederic TYNDIUK (FTLS)       All Rights Reserved.            *
    * E-Mail: [email]tyndiuk@ftls.org[/email]                     Script License: GPL             *
    * Created  02/28/2000                          Last Modified 02/28/2000        *
    * Scripts Archive at:                          [url]http://www.ftls.org/php/[/url]        *
    *******************************************************************************/
    // Necessary Variables:

    $RESULT_FILE_NAME "poll_data.txt";
        
    // En: Absolute path and name to file contain poll data.
        // Fr: Chemin absolu (complet) et Nom du fichier contenant les donne.

    $QUESTION "How do you like this Script?";
        
    // En: Question Text.
        // Fr: Texte de la question.
    $ANSWER = array("Love it!""Like it!""Its okay..""I dislike it""I hate it..");
        
    // En: All answer.
        // Fr: Reponses possibles

    $IMG_DIR_URL "./vote";
        
    // En: URL Directory of poll graphs.
        // Fr: URL du repertoire des images.

    $REVOTE_TIME 0;
        
    // En: Time (second) after people can revote, use cookies.
        // Fr: Temps en second apres lequel une personne peut revoter.

    // End  Necessary Variables section
    /******************************************************************************/

    if (! $vote && ! $result) {
        echo 
    "<FORM METHOD=\"POST\">\n";
        echo 
    "<TABLE WIDTH=100% BORDER=1><TR><TD><TABLE WIDTH=\"100%\" BORDER=0>\n";
        echo 
    "<TR><TH>$QUESTION</TH></TR>\n";
        while (list(
    $key$val) = each($ANSWER)) {
            echo 
    "<TR><TD align=\"center\"><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"> $val</TD></TR>\n";
        }
        echo 
    "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Vote \"></TD></TR>\n";
        echo 
    "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\" See Result \"></TD></TR>\n";
        echo 
    "</TABLE></TD></TR></TABLE></FORM>";
    } else {

        
    $file_array file($RESULT_FILE_NAME); // or error("Can not open \$RESULT_FILE_NAME");

        // En: Save result
        // Fr: Enregistre le resultat
        
    if ($answer count($ANSWER) && $vote) {
            if (
    count($file_array) < count($ANSWER))  {
                
    $file_array = array("0\n""0\n""0\n""0\n""0\n""0\n""0\n""0\n""0\n""0\n");
            }
            
    $old_answer $file_array[$answer];
            
    $old_answer preg_replace("/\n\r*/"""$old_answer);
            
    $file_array[$answer] = ($old_answer 1)."\n";

            
    $file join(''$file_array);
            
    $fp fopen("$RESULT_FILE_NAME""w"); //or error("Can not write \$RESULT_FILE_NAME");
            
    flock($fp1);
            
    fputs($fp$file);
            
    flock($fp3);
            
    fclose($fp);
            echo 
    "Your vote has been added.";
        }

        
    // En: Display result
        // Fr: Affiche le resultat
        
    while (list($key$val) = each($file_array)) {
            
    $total += $val;
        }

        echo 
    "<h2>PHP Poll vote results :</h2>";
        echo 
    "<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>";
        echo 
    "<tr><th>Vote</th><th>Percentage</th><th>Total</th></tr>";

        while (list(
    $key$val) = each($ANSWER)) {
            
    $percent =  $file_array[$key] * 100 $total;
            
    $percent_int floor($percent);
            
    $percent_float number_format($percent1);
            
    $tp += $percent_float;
            echo 
    "<tr><td> $ANSWER[$key] </td><td><img height=9 src=\"$IMG_DIR_URL/vote_left.gif\"><img height=9 width=\"$percent_int\" src=\"$IMG_DIR_URL/vote_middle.gif\"><img height=9 src=\"$IMG_DIR_URL/vote_right.gif\"> $percent_float % </td><td>$file_array[$key]</td></tr>";
        }

        echo 
    "</TABLE><br>";
    }

    ?>
    but just one question:
    where would i edit it to show the poll results on the same page instead of a seperate one?

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Looking at the code it does display the results on the same page as where you will submit your vote from.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

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