|
首先建立0~9這10個GIF數(shù)字圖片,放在img文件夾下,再建立一個php文件
――count1.php,程序如下:
<?
$linkptr=mysql_pconnect("localhost","yourname","password");
mysql_select_db("yourname",$linkptr);
mysql_query("update counter
set visited=visited+1 where num=1",$linkptr);
$result=mysql_query("select visited
from counter where num=1",$linkptr);
list($counter)=mysql_fetch_row($result);
$counter=sprintf("%05d",$counter);
for($i=0;$i<5;$i++){
$tmpstr="<img src=img/".substr($counter,$i,1).".GIF >";
echo $tmpstr;
}
?>
在主頁上適當(dāng)位置放置代碼<? include "count1.php" ?>,這樣主頁上就顯示了你的計數(shù)器,不過要記住在你的數(shù)據(jù)庫上建立一個TABLE――counter:create table counter(
num int unsigned,
visited int unsigned
);
怎么樣,容易吧!中篇我將介紹怎樣讓你的鏡像站也能用上你自己的計數(shù)器。
php技術(shù):打造計數(shù)器DIY三步曲(上),轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。