• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Umfrage Script

Status
Für weitere Antworten geschlossen.

Mars@Gera

Mitglied
Kann mir bitte jemand sagen, wo das Problem in der Zeile 52 sein soll?

PHP:
<?php
$thema = "Homepage Umfrage";
$auswahl = array("Super","Sehr Gut","Gut","Naja","Schlecht");
$farben = array("9999FF","8888FF","7777FF","6666FF","5555FF");
$anzahl = count($auswahl);
?>
<html>
<head>
<title>Homepage - Ergebnis</title>
<link rel="stylesheet" type="text/css" href="css/umfrage.css">
</head>
<body>
<img src='bild/umfragelogo.gif' width='506' height='62'><br>
<h3><?php echo $thema; ?> - Ergebnisse</h3>
<?php
$datei="daten/stimmen.txt";
@$fp=fopen($datei,"r");
@$stimmen=fread($fp,filesize($datei));
@fclose($fp);
// String zerlegen, Array entsteht
$stimmen=explode(",",$stimmen);
for ($i=0;$i<$anzahl;$i++) {
    $gesamt += $stimmen[$i];
}
if ($gesamt>0) {
// Höchstlänge der Balken angeben
$laenge=400;
for ($i=0;$i<$anzahl;$i++) {
// Anteil der Balken
$blaenge=$stimmen[$i]*$laenge/$gesamt;
// Werte auf ganze Zahlen runden
$blaenge= round($blaenge);
// Prozentwert ermitteln und ausgaben
$prozent = sprintf('%1.1f', 100*$stimmen[$i]/$gesamt);
echo "
<table border='0'>
<tr>
<td width='100'>$auswahl[$i]</td>
<td>&nbsp;</td><td width='$blaenge' bgcolor='$farben[$i]'>&nbsp;</td>
<td>&nbsp;<i>$prozent% ($stimmen[$i])</i></td>
</tr>
</table>\;
}
#HIER##-->>echo "<p>Anzahl der Stimmen: <b>$gesamt</b></p>";
} else {
echo "<p>Bisher wurden noch keine Stimmen abgegeben!</p>";
}
?>
</body>
</html>
 
was bitte ist das hier?

PHP:
<?php
echo "
<table border='0'>
<tr>
<td width='100'>$auswahl[$i]</td>
<td>&nbsp;</td><td width='$blaenge' bgcolor='$farben[$i]'>&nbsp;</td>
<td>&nbsp;<i>$prozent% ($stimmen[$i])</i></td>
</tr>
</table>\;
}
echo "<p>Anzahl der Stimmen: <b>$gesamt</b></p>";
} else {
echo "<p>Bisher wurden noch keine Stimmen abgegeben!</p>";
}
?>

korrigier' das mal anständig, dann läufts auch.

Nils aka XraYSoLo
 
Naja das Script beginnt oben schon, haste vllt. übersehen.

Desweiteren ist das nur die Siete wo man die Umfrage ergebniss sieht, also es gibt davor noch ne andere Seite!
 
toll für dich. wenn du net mit dem code 'rausrückst, können wir net helfen. du hast einen ausschnitt gepostet, der war zeimlich falsch, ich hab' dich drauf aufmerksam gemacht.
gut is'.

ist doch völlig egal, ob das script weiter oben beginnt oder nicht. der syntaktische fehler ist der code-ausschnitt und der muss überarbeitet werden, egal, ob das nun das ergebnis der umfrage darstellt oder nicht, es ist falsch.

Nils aka XraYSoLo
 
Ich mache es jetzt so, müsste man sehen:

Code ab hier:

PHP:
[FONT=Courier New][COLOR=#0000bb]<?php
$thema [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"Homepage Umfrage"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];
[/COLOR][COLOR=#0000bb]$auswahl [/COLOR][COLOR=#007700]= array([/COLOR][COLOR=#dd0000]"Super"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"Sehr Gut"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"Gut"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"Naja"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"Schlecht"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
[/COLOR][COLOR=#0000bb]$farben [/COLOR][COLOR=#007700]= array([/COLOR][COLOR=#dd0000]"9999FF"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"8888FF"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"7777FF"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"6666FF"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"5555FF"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
[/COLOR][COLOR=#0000bb]$anzahl [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]count[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$auswahl[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
[/COLOR][/FONT][FONT=Courier New][COLOR=#0000bb]?>
[/COLOR]<html>
<head>
<title>Homepage - Ergebnis</title>
<link rel="stylesheet" type="text/css" href="css/umfrage.css">
</head>
<body>
<img src='bild/umfragelogo.gif' width='506' height='62'><br>
<h3>[COLOR=#0000bb]<?php [/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#0000bb]$thema[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000bb]?>[/COLOR] - Ergebnisse</h3>
[/FONT][FONT=Courier New][COLOR=#0000bb]<?php
$datei[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#dd0000]"daten/stimmen.txt"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];
@[/COLOR][COLOR=#0000bb]$fp[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]fopen[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$datei[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"r"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
@[/COLOR][COLOR=#0000bb]$stimmen[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]fread[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$fp[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000bb]filesize[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$datei[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]));
@[/COLOR][COLOR=#0000bb]fclose[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$fp[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
[/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]// String zerlegen, Array entsteht
[/COLOR][COLOR=#0000bb]$stimmen[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]explode[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]","[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000bb]$stimmen[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
for ([/COLOR][COLOR=#0000bb]$i[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]0[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000bb]$i[/COLOR][COLOR=#007700]<[/COLOR][COLOR=#0000bb]$anzahl[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000bb]$i[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]++) {
    [/COLOR][COLOR=#0000bb]$gesamt [/COLOR][COLOR=#007700]+= [/COLOR][COLOR=#0000bb]$stimmen[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]$i[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]];
}
if ([/COLOR][COLOR=#0000bb]$gesamt[/COLOR][COLOR=#007700]>[/COLOR][COLOR=#0000bb]0[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {
[/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]// Höchstlänge der Balken angeben
[/COLOR][COLOR=#0000bb]$laenge[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]400[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];
for ([/COLOR][COLOR=#0000bb]$i[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]0[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000bb]$i[/COLOR][COLOR=#007700]<[/COLOR][COLOR=#0000bb]$anzahl[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000bb]$i[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]++) {
[/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]// Anteil der Balken
[/COLOR][COLOR=#0000bb]$blaenge[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]$stimmen[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]$i[/COLOR][COLOR=#007700]]*[/COLOR][COLOR=#0000bb]$laenge[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000bb]$gesamt[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];
[/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]// Werte auf ganze Zahlen runden
[/COLOR][COLOR=#0000bb]$blaenge[/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]round[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$blaenge[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
[/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]// Prozentwert ermitteln und ausgaben
[/COLOR][COLOR=#0000bb]$prozent [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]sprintf[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]'%1.1f'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]100[/COLOR][COLOR=#007700]*[/COLOR][COLOR=#0000bb]$stimmen[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]$i[/COLOR][COLOR=#007700]]/[/COLOR][COLOR=#0000bb]$gesamt[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);
echo [/COLOR][/FONT][FONT=Courier New][COLOR=#dd0000]"
<table border='0'>
<tr>
<td width='100'>$auswahl[$i]</td>
<td>&nbsp;</td><td width='$blaenge' bgcolor='$farben[$i]'>&nbsp;</td>
<td>&nbsp;<i>$prozent% ($stimmen[$i])</i></td>
</tr>
</table>\;
}
#HIER##-->>echo "[/COLOR][COLOR=#007700]<[/COLOR][COLOR=#0000bb]p[/COLOR][COLOR=#007700]>[/COLOR][COLOR=#0000bb]Anzahl der Stimmen[/COLOR][COLOR=#007700]: <[/COLOR][COLOR=#0000bb]b[/COLOR][COLOR=#007700]>[/COLOR][COLOR=#0000bb]$gesamt[/COLOR][COLOR=#007700]</[/COLOR][COLOR=#0000bb]b[/COLOR][COLOR=#007700]></[/COLOR][COLOR=#0000bb]p[/COLOR][COLOR=#007700]>[/COLOR][/FONT][FONT=Courier New][COLOR=#dd0000]";
} else {
echo "[/COLOR][COLOR=#007700]<[/COLOR][COLOR=#0000bb]p[/COLOR][COLOR=#007700]>[/COLOR][COLOR=#0000bb]Bisher wurden noch keine Stimmen abgegeben[/COLOR][COLOR=#007700]!</[/COLOR][COLOR=#0000bb]p[/COLOR][COLOR=#007700]>[/COLOR][/FONT][FONT=Courier New][COLOR=#dd0000]";
}
?>
</body>
</html>[/COLOR] [/FONT]
 
immernoch das gleiche, dieser abschnitt hier:

PHP:
<?php
echo "
<table border='0'>
<tr>
<td width='100'>$auswahl[$i]</td>
<td>&nbsp;</td><td width='$blaenge' bgcolor='$farben[$i]'>&nbsp;</td>
<td>&nbsp;<i>$prozent% ($stimmen[$i])</i></td>
</tr>
</table>\;
}
#HIER##-->>echo "<p>Anzahl der Stimmen: <b>$gesamt</b></p>";
} else {
echo "<p>Bisher wurden noch keine Stimmen abgegeben!</p>";
}
?>

ist falsch.

Nils aka XraYSoLo
 
Was ist dass denn jetzt für n Code?

Machs Stück für Stück, nimm erstmal das was Xray gepostet hat und verbessere das mal.
 
Oki ich werde nochmal drüber sehen, aba kannste mal nen kleinen tipp geben, habe heute wahrscheinlich nciht die brille auf!

Danke Marcel
 
Danke erstmal, am besten ich mache das morgen, heute ist nciht mein Tag, ich findes es nicht (am kopf greif)

Gut ich habe es^^

Danke nochmal
 
Zuletzt bearbeitet von einem Moderator:
Status
Für weitere Antworten geschlossen.
Zurück
Oben