mohl by mi pls někdo říct, jak vypočítám dělku toho sloupce, když určím tyto proměnné?
$max_delka; // maximalni mozna delka
$pocet_hlasovani; // kolik lidi hlasovalo za tuhle moznost
$moznosti; // kolik je moznosti
$celkem_hlasovalo; // kolik lidi hlasovalo v cely ankete
Jestli ti pomuze tak ti dam cely kod ankety na kterou si mozna hlasoval na firstpage.wz.cz/anketa/anketa.php ;)
-------------------------------------------------------------------------------
<?
$filename="anketa.txt";
$pruh=50;
if ($hlasuj<>'') {
$hlasoval++;
SetCookie("hlasoval", $hlasoval, Time()+86400);
if ($hlasoval==1) {
$file=FOpen($filename, "r+");
$data=Explode("#",FRead($file,999));
$data[$hlasuj]=$data[$hlasuj]+1;
Rewind($file);
FWrite($file, Implode($data,"#"));
FClose($file);
}else{$alert="Nelze hlasovat vícekrát!";}}
if (File_Exists($filename)):
$file = FOpen($filename, "r+");
$data=Explode("#",FRead($file,999));
Rewind($file);
else:
$file = FOpen($filename, "w");
$data[0]=0;
$data[1]=0;
$data[2]=0;
$data[3]=0;
endif;
FClose($file);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta name="author" content="Rellik 2006">
<title>Anketa</title>
<link rel="stylesheet" type="text/css" href="anketa.css">
</head>
<body>
<TABLE>
<TR>
<TD class="otazka" COLSPAN=2>Jaký preferujete prohlížeč?</TD>
</TR>
<TR>
<TD><A class="hlas" HREF="anketa.php?hlasuj=0">Intenet explorer</A></TD>
</TR>
<TR>
<TD class="pocet"><?if (($data[0]==0)and($data[1]==0)and($data[2]==0)and($data[3]==0)) {echo "0(0%)";}else{?><IMG SRC="sloupec.gif" ALIGN="middle" HEIGHT=10 WIDTH=<?echo round($data[0]/($data[0]+$data[1]+$data[2]+$data[3])*$pruh);?>> <?echo $data[0],"(",round($data[0]/($data[0]+$data[1]+$data[2]+$data[3])*100),"%)";}?></TD>
</TR>
<TR>
<TD><A class="hlas" HREF="anketa.php?hlasuj=1">Mozilu Firefox</A></TD>
<tr>
<TD class="pocet"><?if (($data[0]==0)and($data[1]==0)and($data[2]==0)and($data[3]==0)) {echo "0(0%)";}else{?><IMG SRC="sloupec1.gif" ALIGN="middle" HEIGHT=10 WIDTH=<?echo round($data[1]/($data[0]+$data[1]+$data[2]+$data[3])*$pruh);?>> <?echo $data[1],"(",round($data[1]/($data[0]+$data[1]+$data[2]+$data[3])*100),"%)";}?></TD>
</TR>
<TR>
<TD><A class="hlas" HREF="anketa.php?hlasuj=2">Operu</A></TD>
<tr>
<TD class="pocet"><?if (($data[0]==0)and($data[1]==0)and($data[2]==0)and($data[3]==0)) {echo "0(0%)";}else{?><IMG SRC="sloupec2.gif" ALIGN="middle" HEIGHT=10 WIDTH=<?echo round($data[2]/($data[0]+$data[1]+$data[2]+$data[3])*$pruh);?>> <?echo $data[2],"(",round($data[2]/($data[0]+$data[1]+$data[2]+$data[3])*100),"%)";}?></TD>
</TR>
<TR>
<TD><A class="hlas" HREF="anketa.php?hlasuj=3">Jiný</A></TD>
<TR>
<TD class="pocet"><?if (($data[0]==0)and($data[1]==0)and($data[2]==0)and($data[3]==0)) {echo "0(0%)";}else{?><IMG SRC="sloupec3.gif" ALIGN="middle" HEIGHT=10 WIDTH=<?echo round($data[3]/($data[0]+$data[1]+$data[2]+$data[3])*$pruh);?>> <?echo $data[3],"(",round($data[3]/($data[0]+$data[1]+$data[2]+$data[3])*100),"%)";}?></TD>
</TR>
<TR>
<TD COLSPAN=2 class="celkem">Celkem hlasovalo: <?php echo $data[0]+$data[1]+$data[2]+$data[3]?> </TD>
</TR>
<tr>
<td class="autor">Firstpage.wz.cz</td>
</TR>
</TABLE>
<?if ($alert<>'') {?>
<SCRIPT type="text/javascript">
alert('<?echo $alert?>');
</SCRIPT>
<?}?>
</body>