/* 如果想增加其它的选项可直接加上即可 */ }else{ $descArray=array(1=>"信息量更大", 2=>"网页更精美", 3=>"没什么改进", 4=>"其它" ); $poll_resultBarHeight = 9; // height in pixels of percentage bar in result table $poll_resultBarScale = 1; // scale of result bar (in multiples of 100 pixels) $poll_tableHeader="
"; $poll_rowHeader="
"; $poll_dataHeader="
"; $poll_dataFooter="
"; $poll_rowFooter="
"; $poll_tableFooter="
"; $coutfile="data.pol"; $poll_sum=0;
// read counter-file if (file_exists( $coutfile)) { $fp = fopen( $coutfile, "rt"); while ($Line = fgets($fp, 10)) { // split lines into identifier/counter if (ereg( "([^ ]*) *([0-9]*)", $Line, $tmp)) { $curArray[(int)$tmp[1]] = (int)$tmp[2]; $poll_sum+=(int)$tmp[2]; } } // close file fclose($fp); }else{// for ($i=1;$i<=count($descArray);$i++){ $curArray[$i]=0; } } if(isset($poll)){ $curArray[$poll_voteNr]++; $poll_sum++; } echo $poll_tableHeader;
// cycle through all options编历数组 reset($curArray); while (list($K, $V) = each($curArray)) { $poll_optionText = $descArray[$K]; $poll_optionCount = $V; echo $poll_rowHeader;