View Single Post
  #5   Spotlight this post!  
Unread 27-12-2004, 16:53
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: Counter on a webpage

OK, if you have MySQL. Go into phpmyadmin, make a database (or you can use a pre-existing one), make a table called "hits", in that table have fields:
IP: Varchar(25)
time: Int(14)

On your home page, put this code
PHP Code:
<?php

    
// connect to our mysql server, and select the database
    
mysql_connect("localhost""mysql_username""mysql_password");
    
mysql_select_db("your_db_name");

    
// get the amount of page views
    
$sql    =    mysql_query("SELECT * FROM `hits`");
    
$views    =    mysql_num_rows($sql);

    
// get the amount of unique views
    
$sql    =    mysql_query("SELECT DISTINCT(IP) FROM `hits`");
    
$unique    =    mysql_num_rows($sql);

    
// get the first hit
    
$sql    =    mysql_query("SELECT * FROM `hits` ORDER BY `time` LIMIT 1");
    
$first    =    mysql_fetch_array($sql);

    
// add this hit
    
$sql    =    mysql_query("INSERT INTO `hits` (`IP`, `time`) VALUES ('".$_SERVER['REMOTE_ADDR']."', '".time()."')");

    
// display text
    
echo "There has been ".number_format($views)." page views since ".date("F j, Y"$first['time'])."<br>";
    echo 
number_format($unique)." of those were unique hits.<br>";

?>
IM me if you need more help (MikeWasHere05)
__________________
http://www.mikesorrenti.com/