|
-
Mar 21st, 2002, 10:50 PM
#1
Thread Starter
Fanatic Member
my hit counter
i have my page designed in modules and the page displayed being passed through the address string (values). anbyway, i dont know how to explain that part clearly but its noyt really neccessary for now.
the thing i want to ask is, should i have it only tally one to the counter on the first time the user views the first page, or session ? or even use a cookie and count the user every week or something.
any comments ?
-
Mar 22nd, 2002, 08:40 PM
#2
I'd say have a counter for each page (ie store seperate values for each page, not just one big number) and have it incremented each time the page is viewed.. this is the easiest way and will give you some idea of how many ppl (both new and repeat visitors) visit your page. Cookies don't always work in all circumstances as some people disable them and this can screw up your site if you rely on them.
-
Mar 23rd, 2002, 04:26 AM
#3
Thread Starter
Fanatic Member
ok, thats a good idea actually. should i store their IP's as well ??
-
Mar 23rd, 2002, 07:25 PM
#4
Not unless you have to. The only reason I can think of storing IPs would be to track repeated users, but many ISPs actually assign a dynamic (different) IP each time to dial-up users, so this method of tracking won't always work.
-
Apr 2nd, 2002, 04:41 PM
#5
Addicted Member
how?
How would you create the Hit counter? How do you retrieve a variable from a database file (text file). ?Extract the number from a text file, add 1, then save back to text file? I'm new to PHP. If you want to visit my site @ www.nada.d2g.com\junk.php this is bout the only thing i have made in php so far.
-
Apr 2nd, 2002, 06:40 PM
#6
Thread Starter
Fanatic Member
when i get home i'll post the code 4 u, thing is that now it doesnt appear to be working, but i'll fix it 4 u
-
Apr 3rd, 2002, 04:25 AM
#7
Thread Starter
Fanatic Member
PHP Code:
<?PHP
$link = mysql_connect("localhost", "root");
mysql_select_db("ubunreal");
$temp_page_count = mysql_result(mysql_query("SELECT count FROM counter"),0,"count");
$temp_page_count++;
mysql_query("UPDATE counter SET count=$temp_page_count");}
ECHO mysql_result(mysql_query("SELECT count FROM counter"),0,"count");
?>
there is the code i use, made it myself too anyway, it simply logs into a MySQL DB server and extracts the existing value in the cell, adds one to it then runs another query to replace the updated value, after that there is another query to get the resuly back out and display it to the HTML output.
need any more explanation then pls just ask
-
Apr 3rd, 2002, 11:43 AM
#8
There's plenty of free counters out there that do all of the above and more.
Do a search on SourceForge or on Google.
-
Apr 3rd, 2002, 11:53 AM
#9
Fanatic Member
Bah make it yourself its much more rewarding
-
Apr 3rd, 2002, 12:20 PM
#10
I do most of my code myself, but I do occasionally scarf bits from Open Source things.
-
Apr 3rd, 2002, 06:27 PM
#11
Thread Starter
Fanatic Member
Bah make it yourself its much more rewarding
couldnt agree more, thats why i try and do everything mysqlf before seeking other peoples code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|