Nieuw lid |
|
Hallo allemaal,
Ik heb een script van internet voor een poll gebruikt.
Nu lukt het me alleen niet om de vraag, antwoorden en stem-knop dichter bij elkaar te krijgen. Er zit nu nog een flinke ruimte tussen de items.
Kan iemand me vertellen hoe ik dit kan doen?
Hier kun je de poll vinden.
En hier de code:
<?php
// Deze moet je zeker invullen !!:
$RESULT_FILE_NAME = "poll_data.txt";
// schrijf hier het bestand naar waar hij schrijft
$QUESTION = "Is dit een test?";
// Schrijf hier de vraag van je poll.
$ANSWER = array("Ja", "Nee");
// zet hier alle antwoorden
$IMG_DIR_URL = "./vote";
// map waar afbeelding voor poll wordt opgeslaan bij deze in de map vote dus
$REVOTE_TIME = 3600;
// Tijd tussen herstemmen
// Begin Poll
/******************************************************************************/
if (! $vote && ! $result) {
echo "<FORM METHOD=\"POST\">";
echo "<TABLE WIDTH=100% BORDER=0><TR><TD><TABLE WIDTH=\"100%\" BORDER=0>";
echo "<TR><TH style=\"font-family: 'Arial'; font-size: 10px;\"><left>$QUESTION</left></TH></TR>";
echo "</TABLE>";
while (list($key, $val) = each($ANSWER)) {
echo "<TR><TD><TABLE WIDTH=\"30%\" BORDER=0 cellspacing=0>";
echo "<TR><TD align=\"right\" height='5' width=20%><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\" style=\"font-family: 'Arial'; font-size: 10px;\"></TD><td width=20% height='5' style=\"font-family: 'Arial'; font-size: 10px;\">$val</td></TR>";
echo "</table>";
}
echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Stem \" style=\"font-family: 'Arial'; font-size: 10px; font-weight: bold; text-align: center; border-style: solid; border-width: 0\"></TD></TR>";
echo "</TABLE></TD></TR></TABLE></FORM>";
} else {
$file_array = file($RESULT_FILE_NAME); // or error("Can not open \$RESULT_FILE_NAME");
// het opslaan van de resultaten
if ($answer < count($ANSWER) && $vote) {
if (count($file_array) < count($ANSWER)) {
$file_array = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
}
$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($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
echo "";
}
// weergeven van de resultaten
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<center><h5>Poll Resultaten :</h5></center>";
echo "<TABLE CELLSPACING=2 CELLPADDING=2 BORDER=0 align=left>";
echo "<tr><th width='30%' style=\"font-family: 'Arial'; font-size: 10px;\">What</th><th width='30%' style=\"font-family: 'Arial'; font-size: 10px pt;\">Percentage</th><th style=\"font-family: 'Arial'; font-size: 10px;' width='40%'\"> </th></tr>";
while (list($key, $val) = each($ANSWER)) {
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
echo "<tr><td style=\"font-family: 'Arial'; font-size: 10px;\"> $ANSWER[$key] </td><td style=\"font-family: 'Arial'; font-size: 10px;\"><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\"><br> $percent_float % ($file_array[$key])</td><td style=\"font-family: 'Arial'; font-size: 7 pt;' width='%'\"> </td></tr>";
}
echo "</TABLE><br>";
}
if (isset($HTTP_COOKIE_VARS["votingstep"])) {
setcookie("votingstep","1",time()+1);}
?>
<?php // Deze moet je zeker invullen !!: $RESULT_FILE_NAME = "poll_data.txt"; // schrijf hier het bestand naar waar hij schrijft $QUESTION = "Is dit een test?"; // Schrijf hier de vraag van je poll. $ANSWER = array("Ja", "Nee"); // zet hier alle antwoorden $IMG_DIR_URL = "./vote"; // map waar afbeelding voor poll wordt opgeslaan bij deze in de map vote dus $REVOTE_TIME = 3600; // Tijd tussen herstemmen // Begin Poll /******************************************************************************/ if (! $vote && ! $result) { echo "<FORM METHOD=\"POST\">"; echo "<TABLE WIDTH=100% BORDER=0><TR><TD><TABLE WIDTH=\"100%\" BORDER=0>"; echo "<TR><TH style=\"font-family: 'Arial'; font-size: 10px;\"><left>$QUESTION</left></TH></TR>"; while (list($key, $val) = each($ANSWER)) { echo "<TR><TD><TABLE WIDTH=\"30%\" BORDER=0 cellspacing=0>"; echo "<TR><TD align=\"right\" height='5' width=20%><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\" style=\"font-family: 'Arial'; font-size: 10px;\"></TD><td width=20% height='5' style=\"font-family: 'Arial'; font-size: 10px;\">$val</td></TR>"; } echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Stem \" style=\"font-family: 'Arial'; font-size: 10px; font-weight: bold; text-align: center; border-style: solid; border-width: 0\"></TD></TR>"; echo "</TABLE></TD></TR></TABLE></FORM>"; } else { $file_array = file($RESULT_FILE_NAME); // or error("Can not open \$RESULT_FILE_NAME"); // het opslaan van de resultaten if ($answer < count($ANSWER) && $vote) { $file_array = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0"); } $old_answer = $file_array[$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"); } // weergeven van de resultaten while (list($key, $val) = each($file_array)) { $total += $val; } echo "<center><h5>Poll Resultaten :</h5></center>"; echo "<TABLE CELLSPACING=2 CELLPADDING=2 BORDER=0 align=left>"; echo "<tr><th width='30%' style=\"font-family: 'Arial'; font-size: 10px;\">What</th><th width='30%' style=\"font-family: 'Arial'; font-size: 10px pt;\">Percentage</th><th style=\"font-family: 'Arial'; font-size: 10px;' width='40%'\"> </th></tr>"; while (list($key, $val) = each($ANSWER)) { $percent = $file_array[$key] * 100 / $total; $percent_int = floor($percent); $tp += $percent_float; echo "<tr><td style=\"font-family: 'Arial'; font-size: 10px;\"> $ANSWER[$key] </td><td style=\"font-family: 'Arial'; font-size: 10px;\"><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\"><br> $percent_float % ($file_array[$key])</td><td style=\"font-family: 'Arial'; font-size: 7 pt;' width='%'\"> </td></tr>"; } } if (isset($HTTP_COOKIE_VARS["votingstep"])) { ?>
|