Autor Zpráva
Aaadam
Profil
caute,
spravil som malu anketu v php (len sa ucim) ale nefunguje... Uz som nad tym rozmyslal aj s kamaratom ale nevieme si rydy. Tu je zdrojak... Ono sa to vlastne vobec nepripocitava (hlasy) a ani to poriadne neukazuje 100 % atd... v suboroch yes.txt a no.txt je ulozene "1" aby nebolo delenie nulou...
Aaadam

<style type="text/css">
body, html{ color:silver; background-color: black; font-size:15px; font-style:Arial;}
#divyes { background-color:green; border: 1px solid Lime; height:15px}
#divno ( background-color:maroon; border: 1px solid red; height:15px)
font { color:silver; font-size:15px; font-style:Arial; font-weight:bold;}
h1 { font-color:#BBDBFF; font-size:20px; font-style:Helvetica; text-decoration:none;}
</style>
<?php
if (!$_REQUEST["odoslane"]){
?>
<form action="inquiry.php" method="post">
<p>Do you like my Web?</p>
<p><input type="radio" name="anketa" value="yes"CHECKED>Yes</p>
<p><input type="radio" name="anketa" value="no">No</p>
<p><input type="hidden" name="odoslane" value="1"></p>
<p><input type="submit" name="submit" value="Send" name="send"></p>
</form>
<?
}
else{
//Tu sa to msui nacitavat zo suboru
define("YES", "yes.txt");
if(file_exists(YES)){
$fileYes = fopen(YES, "r+");
$i = fread($fileYes, 10);
}
else {
$fileYes=fopen(YES, "w");
$i=1;
}
define("NO", "no.txt");
if(file_exists(NO)){
$fileNo = fopen(NO, "r+");
$k = fread($fileNo, 10);
}
else {
$fileNo=fopen(NO, "w");
$k=1;
}

$j = $i / ($i + $k);
$l = $l / ($i + $k);

if( $_HTTP_POST_VARS["yes"]) {
++$i;
rewind($fileYes);
fwrite($fileYes, $i, 10);
fclose($fileYes);
fclose($fileNo);
$sirkaYes = 170 * $j;
$j *= 100;
$l *= 100;
}
elseif ( $_HTTP_POST_VARS["no"]) {
++$k;
rewind($fileNo);
fwrite($fileNo, $k, 10);
fclose($fileYes);
fclose($fileNo);
$sirkaNo = 170 * $l;
$l *= 100;
$j *= 100;
}
?>
<table width=200 height=200 border=1 color=white style="border:1px solid white">
<tr width="200">
<td colspan=2 width="100%">
<h1>Anketa</h1>
</td>
</tr>
<tr width=200>
<td width=30><font>Yes:</font></td>
<td width=170>
<span id="divyes" style=" width: <? $sirkaYes; ?>;">
<? echo $j; ?> %
</span>
</td>
</tr>
<tr width=200>
<td width=30><font>No:</font></td>
<td width=170>
<span id="divno" style=" width: <? $sirkaNo; ?>;">
<? echo $l; ?> %
</span>
</td>
</tr>
</table>
<?
}
?>
WertriK
Profil *
Jelikoz jsi jmenovec, tak jsem se "obetoval". Treba to bude behat ....

<style type="text/css">
body, html{ color:silver; background-color: black; font-size:15px; font-style:Arial;}
#divyes { background-color:green; border: 1px solid Lime; height:15px}
#divno ( background-color:maroon; border: 1px solid red; height:15px)
font { color:silver; font-size:15px; font-style:Arial; font-weight:bold;}
h1 { font-color:#BBDBFF; font-size:20px; font-style:Helvetica; text-decoration:none;}
</style>
<?php

//Tu sa to msui nacitavat zo suboru
define("YES", "yes.txt");
if(file_exists(YES)){
$fileYes = fopen(YES, "r+");
$i = fread($fileYes, 10);
}
else {
$fileYes=fopen(YES, "w");
$i=1;
}
define("NO", "no.txt");
if(file_exists(NO)){
$fileNo = fopen(NO, "r+");
$k = fread($fileNo, 10);
}
else {
$fileNo=fopen(NO, "w");
$k=1;
}

// pokud jsme neodeslali
if (!$_REQUEST["odoslane"]){
?>
<form action="inquiry.php" method="post">
<p>Do you like my Web?</p>
<p><input type="radio" name="anketa" value="yes"CHECKED>Yes</p>
<p><input type="radio" name="anketa" value="no">No</p>
<p><input type="hidden" name="odoslane" value="1"></p>
<p><input type="submit" name="submit" value="Send" name="send"></p>
</form>
<?
}
else{
// pokud jsme odeslali

if($_POST["yes"]) {
$i++;
rewind($fileYes);
fwrite($fileYes, $i, 10);
fclose($fileYes);
fclose($fileNo);
$sirkaYes = 170 * $j;

}
elseif ($_POST["no"]) {
$k++;
rewind($fileNo);
fwrite($fileNo, $k, 10);
fclose($fileYes);
fclose($fileNo);
$sirkaNo = 170 * $l;

}
}

$j = ($i / ($i + $k)) * 100;
$l = ($l / ($i + $k)) * 100;

?>
<table width=200 height=200 border=1 color=white style="border:1px solid white">
<tr width="200">
<td colspan=2 width="100%">
<h1>Anketa</h1>
</td>
</tr>
<tr width=200>
<td width=30><font>Yes:</font></td>
<td width=170>
<span id="divyes" style=" width: <? $sirkaYes; ?>;">
<? echo $j; ?> %
</span>
</td>
</tr>
<tr width=200>
<td width=30><font>No:</font></td>
<td width=170>
<span id="divno" style=" width: <? $sirkaNo; ?>;">
<? echo $l; ?> %
</span>
</td>
</tr>
</table>
Aaadam
Profil
stale to nefunguje... zmenil som aj subory na *.dat a aj tak.... inac co je presne toto: $k = fread($fileNo, 10); myslim tu 10. nemalo by to okrem citania a zapisania noveho cilsla aj to predosle vymazat??? löebo myslim ze to nerobi
Toto téma je uzamčeno. Odpověď nelze zaslat.

0