Imam mali problem sa anketom za sajt..
Anketa radi sve normalno ti nije problem nego mi se iznad glasanja pokazuje ovo...
Isao sam do te linije i pokusavao nesto ali jbg nisam uspeo...
Sve super sljaka postavim anketu odgovorim onda me prebaci do rezultata i tu se pojavljuje iznad rezultata ovo
Notice: Undefined variable: totalCount in C:\wamp\www\Anketa\index.php on line 80
A ovo je deo koda gde se nalazi linija 80
78. <?php
79. foreach ($answers as $value) {
80. echo '<tr><td> '.$value['text'].'</td><td>'.$value['count'].'</td></tr>';
}
?>
Evo i clog coda index.php
<?php
$pollQuestion = '';
$answers = '';
function readData(){
global $pollQuestion,$answers;
// Read configuration
$rawdata = file('polldata.txt');
// Get the question for polling
$pollQuestion = $rawdata[0];
// Get number of answers - The foirs row is the question
$numberOfAnswers = sizeof($rawdata)-1;
$count = 0;
for ($i=1; $i <= $numberOfAnswers; $i++){
$answerData = explode(':',$rawdata[$i]);
// If tha actual row is not empty than add to the answers array
if (strlen(trim($answerData[0]))>0){
$answers[$count]['text'] = $answerData[0];
$answers[$count]['count'] = $answerData[1];
++$count;
}
}
}
function writeData(){
global $pollQuestion,$answers;
$file = fopen('polldata.txt','w');
fwrite($file,$pollQuestion."\r\n",strlen($pollQuestion));
foreach ($answers as $value) {
$row = $value['text'].':'.$value['count']."\r\n";
fwrite($file,$row,strlen($row));
}
fclose($file);
}
readData();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Anketa</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<?php if (!isset($_POST['submitBtn'])) { ?>
<div class="caption"><?php echo $pollQuestion; ?></div>
<div id="icon"> </div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="poll">
<table width="300">
<?php
foreach ($answers as $value) {
echo '<tr><td><input type="radio" name="polling" value="'.$value['text'].'"/> '.$value['text'].'</td></tr>';
}
?>
<tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Vote" /></td></tr>
</table>
</form>
<?php
} else {
$count = 0;
foreach ($answers as $value) {
if ($value['text'] == $_POST['polling']) {
$answers[$count]['count'] = ((int)$value['count'])+1;
(int)$totalCount++;
}
++$count;
}
writeData();
?>
<div class="caption">Hvala Na Glasanju<div>
<div id="icon"> </div>
<div id="result">
<table width="300">
<?php
foreach ($answers as $value) {
echo '<tr><td> '.$value['text'].'</td><td>'.$value['count'].'</td></tr>';
}
?>
</table>
</div>
<?php } ?>
<div id="source">By_Ivan</div>
</div>
</body>
|