View Single Post
  #7   Spotlight this post!  
Unread 28-12-2004, 01:45
Mike AA's Avatar
Mike AA Mike AA is offline
Programmer and Mentor
AKA: Mike Aalderink
FRC #3458 (Code Blue)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Holland, Mi
Posts: 698
Mike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to behold
Send a message via MSN to Mike AA
Re: Counter on a webpage

Quote:
Originally Posted by MikeWasHere05
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)

sounds like what I want to do. I guess I'll download and install Mysql tomorrow. I just got on to check for any other ideas. Still havent gotten it to work, but didnt have much chance.