改進(jìn)的IP計(jì)數(shù)器
更新時(shí)間:2006年10月09日 00:00:00 作者:
<?
//require ('common.inc');
$arr_request=array();
if (count($HTTP_GET_VARS))
{
while (list($key,$value)=each($HTTP_GET_VARS))
{
$arr_request[strtolower($key)]=$value;
}
}
if (count($HTTP_POST_VARS))
{
WHILE (list($key,$value)=each($HTTP_POST_VARS))
{
$arr_request[strtolower($key)]=$value;
}
}
$link=@mysql_connect("localhost","kong","kong");
mysql_select_db("mywebdb");
$ip=$REMOTE_ADDR;
$current=getdate(time());
$day=$current["mday"];
$query="select * from addcount where day=\"$day\"";
$result=@mysql_query($query);
if(!$num=@mysql_num_rows($result))
$num=1;
while($row=@mysql_fetch_row($result))
{
if (strcmp($ip,$row[1])==0)
{
$i=1;
$id=$row[0];
$click=$row[3]+1;
$up="update addcount set click_count=click_count+1 where id=$id";
$result2=@mysql_query($up);
// break;
}
$total+=$row[3];
}
$total++;
if(!$i){
$query1="insert into addcount (ip,day,click_count )values ('$ip','$day',1)";
mysql_db_query("mywebdb",$query1,$link);
$click=1;
}
echo "<html><head><title>計(jì)數(shù)器</title></head>";
echo "你是第" .$num."訪問(wèn)者<BR>";
echo "今天你第".$click."次點(diǎn)擊<BR>";
echo "今天總點(diǎn)擊".$total."次<BR>";
/*
表:
addcount
CREATE TABLE addcount (
id int(6) DEFAULT '0' NOT NULL auto_increment,
ip char(20) NOT NULL,
day int(2) NOT NULL,
click_count int(3) NOT NULL,
PRIMARY KEY (id)
);
*/
?>
//require ('common.inc');
$arr_request=array();
if (count($HTTP_GET_VARS))
{
while (list($key,$value)=each($HTTP_GET_VARS))
{
$arr_request[strtolower($key)]=$value;
}
}
if (count($HTTP_POST_VARS))
{
WHILE (list($key,$value)=each($HTTP_POST_VARS))
{
$arr_request[strtolower($key)]=$value;
}
}
$link=@mysql_connect("localhost","kong","kong");
mysql_select_db("mywebdb");
$ip=$REMOTE_ADDR;
$current=getdate(time());
$day=$current["mday"];
$query="select * from addcount where day=\"$day\"";
$result=@mysql_query($query);
if(!$num=@mysql_num_rows($result))
$num=1;
while($row=@mysql_fetch_row($result))
{
if (strcmp($ip,$row[1])==0)
{
$i=1;
$id=$row[0];
$click=$row[3]+1;
$up="update addcount set click_count=click_count+1 where id=$id";
$result2=@mysql_query($up);
// break;
}
$total+=$row[3];
}
$total++;
if(!$i){
$query1="insert into addcount (ip,day,click_count )values ('$ip','$day',1)";
mysql_db_query("mywebdb",$query1,$link);
$click=1;
}
echo "<html><head><title>計(jì)數(shù)器</title></head>";
echo "你是第" .$num."訪問(wèn)者<BR>";
echo "今天你第".$click."次點(diǎn)擊<BR>";
echo "今天總點(diǎn)擊".$total."次<BR>";
/*
表:
addcount
CREATE TABLE addcount (
id int(6) DEFAULT '0' NOT NULL auto_increment,
ip char(20) NOT NULL,
day int(2) NOT NULL,
click_count int(3) NOT NULL,
PRIMARY KEY (id)
);
*/
?>
相關(guān)文章
在apache下限制每個(gè)虛擬主機(jī)的并發(fā)數(shù)?。。?!
在apache下限制每個(gè)虛擬主機(jī)的并發(fā)數(shù)!?。?!...2006-10-10php單例模式實(shí)現(xiàn)(對(duì)象只被創(chuàng)建一次)
這是我在php面試題中遇到的一道試題,單例模式按字面來(lái)看就是某一個(gè)類只有一個(gè)實(shí)例,這樣做的好處還是很大的,比如說(shuō)數(shù)據(jù)庫(kù)的連接,我們只需要實(shí)例化一次,不需要每次都去new了,這樣極大的降低了資源的耗費(fèi)2012-12-12解決MySQL中文輸出變成問(wèn)號(hào)的問(wèn)題
最初我在顯示MySQL時(shí)遇到顯示出的中文字符全部變成了問(wèn)號(hào)。2008-06-06PHP開(kāi)發(fā)文件系統(tǒng)實(shí)例講解
PHP開(kāi)發(fā)文件系統(tǒng)實(shí)例講解...2006-10-10選擇PHP作為網(wǎng)站開(kāi)發(fā)語(yǔ)言的原因分享
如今大多數(shù)的編程語(yǔ)言都能夠有效的處理復(fù)雜的任務(wù),支持多種數(shù)據(jù)庫(kù)并且兼容于多平臺(tái)。但是,當(dāng)一個(gè)網(wǎng)站選擇用何種語(yǔ)言開(kāi)發(fā)時(shí)應(yīng)當(dāng)更注重語(yǔ)言的成本和靈活性2012-01-01用PHP來(lái)寫(xiě)記數(shù)器(詳細(xì)介紹)
利用一個(gè)文本文件實(shí)現(xiàn)多個(gè)頁(yè)的計(jì)數(shù)減少服務(wù)器的I/O占用率在需要紀(jì)錄的文件里,只需加入很少的幾行代碼2006-10-10php radio 單選框獲取與保持值的實(shí)現(xiàn)代碼
php中讀取單選框radio值的與在php中保持單選按鈕的值的方法,其實(shí)都是一樣的原理。2010-05-05