Go Back   Gaming Gutter > Non-Gaming > Programming > Source Code


Source Code - Have a source code/project files you want to post? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post My formal on Friday
11-17-2008 05:12 AM
by Bex
Last post by Bex
Today 10:17 PM
11 Replies, 50 Views
Go to first new post Paypal help?
Today 10:11 PM
by 1x1
Last post by 1x1
Today 10:11 PM
0 Replies, 1 Views
Go to first new post NextGenWarrior = scammer
Yesterday 10:29 PM
by Peanuts
Last post by Jakious
Today 10:08 PM
13 Replies, 121 Views
Go to first new post Do you think smoking is...
08-16-2008 07:09 PM
Last post by kemoomek
Today 10:07 PM
249 Replies, 2,602 Views
Go to first new post People that use...
10-26-2008 01:50 PM
by kiasyn
Last post by Jakious
Today 10:05 PM
23 Replies, 664 Views
Reply
 
LinkBack Thread Tools Display Modes

 [PHP] Hit Counter
Old 12-10-2006, 03:11 PM   #1 (permalink)
emit
Guest

 
Posts: n/a
GPoints: 0 [Check]
iTrader: / %
Post [PHP] Hit Counter

PHP - HIT COUNTER USING MYSQL

Here's how to host your own hit counter using PHP and MySQL, including the exact time of counts.
Use phpMyAdmin to create a new table in your MySQL database. Or if you are comfortable with PHP, write a script instead.
Open your phpMyAdmin then click on your database then on SQL at the top.
In that box type:

PHP Code:

CREATE TABLE 
`counter` (

  `
idint(10NOT NULL auto_increment,

  `
datevarchar(225NOT NULL default '',

  
PRIMARY KEY  (`id`)

); 
Now that the table is all set up, you need to add some script to your page.
Open up your homepage and in your head tags enter this code:

PHP Code:
<?

$connect 
mysql_connect(HOSTNAME,USERNAME,PASSWORD);

if (!
$connect) { echo("ERROR: " mysql_error() . "\n"); }



mysql_select_db("DATABASE NAME"$connect);



$date date("l, j.n.Y g:i a");



$SQL " INSERT INTO counter ";

$SQL $SQL " (date) VALUES ";

$SQL $SQL " ('$date') ";

$result mysql_db_query(DATABASENAME,"$SQL",$connect);

if (!
$result) { echo("ERROR: " mysql_error() . "\n$SQL\n"); }



?>
This snippet goes where you want the counter to appear on your page:

PHP Code:
  <?



$db 
"DATABASE NAME";



$connect mysql_connect(HOSTNAME,USERNAME,PASSWORD);

if (!
$connect) { echo("ERROR: " mysql_error() . "\n"); }



mysql_select_db($db);



$SQL "SELECT * FROM counter ORDER BY id DESC LIMIT 1";



$retid mysql_db_query($db$SQL$connect);



while (
$row mysql_fetch_array($retid)) {

$id $row["id"];



print(
"$id");

}



?>
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 10:26 PM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.08422089 seconds (100.00% PHP - 0% MySQL) with 17 queries