<?
if($ch!="") {
$ch=$ch.":";
$line=file("$id.txt");
$nline=sizeof($line);
for($i=0;$i<$nline;$i++) {
$line[$i]=trim($line[$i]);
if(ereg("^$ch",$line[$i])) {
$Count=substr($line[$i],strrpos($line[$i],":")+1)+1;
$line[$i]=substr($line[$i],0,strrpos($line[$i],":")+1).$Count;
}
if(strlen($line[$i])>1) {
$tmp=$tmp.$line[$i]."\n";
}
}
$fv=fopen("$id.txt","w");
fwrite($fv,$tmp);
fclose($fv);
}
$fn = "$id.txt";
if(!file_exists("$id.txt")) {
echo "äÁèÁÕ poll id ¹Õé<br>";
exit();
}
$buffer = file($fn);
$nline = sizeof($buffer);
$img = array("1","2","3","4","5","6","7","8","9","10");
for($i=0 ; $i<$nline;$i++) {
$buffer[$i] = trim($buffer[$i]);
$score[$i] = substr($buffer[$i],strrpos($buffer[$i],":")+1);
$total += $score[$i];
}
for($i=0 ; $i<$nline;$i++) {
$buffer[$i] = trim($buffer[$i]);
$chname[$i] = substr($buffer[$i],0,strrpos($buffer[$i],":"));
$score[$i] = substr($buffer[$i],strrpos($buffer[$i],":")+1);
$percent[$i] = sprintf("%4.1f",$score[$i] / $total *100);
echo "<tr>";
echo "<td width='70%' bgcolor='FFFFFF'><font face='MS Sans Serif' size='2'> $chname[$i]<br> <img src='$imgurl/$img[$i].gif' width='".round($percent[$i])."%' height='10'></font></td>";
echo "<td width='15%' bgcolor='FFFFFF' align='right'><font face='MS Sans Serif' size='2'>$score[$i] </font></td>";
echo "<td width='15%' bgcolor='FFFFFF' align='right'><font face='MS Sans Serif' size='2'>$percent[$i] % </font></td>";
echo "</tr>";
}
?>
จากโค้ดข้างบนนี้ ผมอยากให้มันกำหนดว่าโหลตได้ 1 ชั่วโมงต่อ 1 ครั้ง
เขียนเพิ่มยังไงครับ ขอบคุณครับ