counter در php

salam bacheha man yek zamani barnameye kamele counter dar php
ra dar inja dide boodam kesi linkesho midoone ya inke barnamasho
kamel dare?
mishe vasam befrestid
man ta farda mikhamesh
 
مي خواهم تعداد افرادي كه وارد سايت ميشه را واسم مشخص كنه كه تا حالا چند نفر وارد سايت شدند
 

AliReza26

Active Member
بفرما :

کد:
<?php
//this is our text file if you create a different named file change the script below to reflect this
$counter_file = ("counter.txt");
//now we open the file
$visits = file($counter_file);
//this increments the counter value by 1
$visits[0]++;
//now we will open the counter file for writing "w"
$fp = fopen($counter_file , "w");
//put the new count value into the counter file
fputs($fp , "$visits[0]");
//close the file
fclose($fp);
//display the count
echo "There have been $visits[0] visitors so far";
?>
 

NabiKAZ

Well-Known Member
سلام
از اين ورا رد ميشدم گفتم يه چيزي بنويسم.
اين هم روش ديتا بيسيش :

جدول ديتا بيس مورد نياز:
کد:
CREATE TABLE `counter` (
  `type` varchar(100) NOT NULL default '',
  `count` int(50) NOT NULL default '0'
) TYPE=MyISAM;
INSERT INTO `counter` VALUES ('total', 1);

شمارنده خودكار كنتر:
کد:
$Query = "update counter set count=count+1 where (type='total')";

خواندن مقدار فعلي كنتر:
کد:
$Query = "SELECT count FROM $TableName WHERE type='total'";

اميدوارم مفيد بوده باشه
باتشكر
نبي 8)
 

جدیدترین ارسال ها

بالا