作者GoliathPlus (Taiwan Yes !)
看板Web_Design
標題Re: [問題] 有關計數器
時間Thu May 5 12:52:05 2005
修改如下
in a.htm
<?php
include("count.php");
?>
in b.htm
<?php
include("countpic.php");
for ($array_id = 1;$array_id < $array_elements; ++ $array_id) {
echo ("<img src=images/counter/$counter_array[$array_id].gif></img>");
}
?>
count.php檔如下:
<?php
$countfile = "counter.dat";
if (($fp = fopen($countfile, "r+")) == false) {
printf ("Open file %s failed!",$countfile);
exit;
}
else
{
$count = fread ($fp,filesize($countfile));
$count = $count + 1;
fclose ($fp);
$fp = fopen($countfile, "w+");
fwrite ($fp,$count);
fclose ($fp);
}
?>
countpic.php檔如下:
<?php
$countfile = "counter.dat";
$fp = fopen ($countfile, "r");
$array_count = 1;
while (! feof($fp)) {
$current_number = fgetc($fp);
$counter_array[$array_count] = $current_number;
$array_elements = count ($counter_array);
$array_count = $array_count + 1;
}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.151.64
1F:推 urchinyun:馬上用馬上可以 真是太感謝了!!!140.122.140.202 05/05