View Full Version : IP Log

06-09-2007, 03:47 PM
Ive made ip logger for my site. Is there anyway to make it so that it only logs the same ip once a day e.g. so that it doesnt apper in the log more than once? Also i was looking to make it so it only displays 25 ip's on a page and when 25 ip's are logged it automaticly creates a new page.
Thanks :thumbsup:

06-09-2007, 04:11 PM
I'm assuming you're using a database?

If so, to only log one IP per day


//assumes you're already connected to the database
//This assumes you have a variable with todays date named $date
$query = "SELECT * FROM `table` WHERE `date_inserted` = $date AND `ip` = $ip";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
//There is already an IP from today in the database
$addip = false;
$addip = true;
$query = "INSERT INTO `table`(columns here) VALUES (values here)";

Using a database, you only need one page to display all the IPs. You can limit the number shown by only withdrawing 25 IPs at a time. Using a $_GET var, the page can figure out which set of results to pull from the database:

http://www.mysite.com/showips.php -- shows IPs 1-25
http://www.mysite.com/showips.php?page=2 -- shows IPs 26-50
http://www.mysite.com/showips.php?page=3 -- shows IPs 51-75


06-09-2007, 04:16 PM
thanks ill give it a try :D