digiTALE
Lt. Junior Grade
- Registriert
- Juli 2004
- Beiträge
- 270
Hallo,
habe ein UmfrageScript, funktioniert auch einwandfrei. Nur wollte ich eine 2 Umfrage mit einfügen und habe das gleiche Script benutzt, aber an welchen sstellen muss ich das ändern damit es sich nicht in die Quere kommt !?
Das Script kommt ohne MySQL aus, wär schön wenn mir jemand helfen könnte
habe ein UmfrageScript, funktioniert auch einwandfrei. Nur wollte ich eine 2 Umfrage mit einfügen und habe das gleiche Script benutzt, aber an welchen sstellen muss ich das ändern damit es sich nicht in die Quere kommt !?
Das Script kommt ohne MySQL aus, wär schön wenn mir jemand helfen könnte
PHP:
<?php
$varia=file("php/1_frage.txt","r");
$frage=array_pop($varia);
echo "<div class=\"main_text\"><b>$frage <font color=\"cc0000\"> *</font></b><br><br />";
echo "<table width=\"660\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr />";
echo "<td width=\"240\" valign=\"top\" class=\"umfrage\">";
echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">";
$i=0;
while(isset($varia[$i])) {
$j=$i+1;
echo "<input type=\"radio\" name=\"ant\" value=\"$j\"> $varia[$i]<br />";
$i++;
}
echo "<br />";
echo "<input type=\"submit\" value=\"Abstimmen\" class=\"button\"></form>";
echo "<td width=\"420\" valign=\"top\" class=\"umfrage\">";
$z=file("php/1_antwort.txt","r");
if ($ant!='') {
$lvote=fopen("php/1_ip.txt","r");
$lv=fgets($lvote,255);
fclose($lvote);
$ip=getenv("REMOTE_ADDR");
if ($lv!=$ip) {
$z[$ant-1]=$z[$ant-1]+1;
$datei=fopen("php/1_antwort.txt","w");
foreach ($z as $save) {fputs($datei,chop($save)."\n");}
fclose($datei);
$lvote=fopen("php/1_ip.txt","w");
fputs($lvote,"$ip");
fclose($lvote);
}
}
$laenge=300;
$gesamt=0;
foreach($z as $zahl)
{ $gesamt=$gesamt+$zahl; }
$proz=array();
foreach ($z as $zahl) {
if ($gesamt!=0) {
$p=round($zahl/$gesamt*10000)/100;
array_push($proz,$p);
}
}
$max=1;
foreach ($z as $zahl) {
$zahl=$zahl*10/10;
if($zahl > $max) { $max=$zahl; }
}
$breite=array();
foreach ($z as $zahl)
{
$b=$zahl*$laenge/$max;
array_push($breite,$b);
}
$i=0;
while (isset($z[$i]))
{
echo "$varia[$i]<br />";
echo "<img src=\"img/grau_1.png\" width=\"3\" height=\"12\" align=\"absmiddle\"><img src=\"img/grau_2.png\" width=\"$breite[$i]\" height=\"12\" align=\"absmiddle\"><img src=\"img/grau_3.png\" width=\"3\" height=\"12\" align=\"absmiddle\">";
echo " <b>$proz[$i]%</b>";
echo "<br />";
$i++;
}
echo "<br /><b>Stimmen: $gesamt (100%)</b></td>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
?>
Anhänge
Zuletzt bearbeitet von einem Moderator: