The easy way which can show the remote visit ip
visitip.php
<?php
include_once "datasource.inc.php";
$date = Date("Y-m-d H:i:s");
//$date_Y = substr($row['date'],0,4);
//$date_M = substr($row['date'],5,2);
//$date_D = substr($row['date'],8,2);
//$showdate=$date_D."-".$date_M."-".$date_Y;
$visitip=$_SERVER[REMOTE_ADDR];
$count=1;
$query1="INSERT INTO `rip` ( `ip`, `count`,`showdate`) VALUES ('$visitip', '$count','$date')";
$query3="SELECT count,ip FROM `rip` where ip='$visitip'";
$result=mysql_query($query3);
$r=mysql_fetch_array($result);
if ($r["ip"]==$visitip)
{
$count=$r["count"];
$count++;
$query2="update rip set count=$count,showdate='$date' where ip='$visitip'";
mysql_query($query2);
// echo $query2;
}
else
{
mysql_query($query1);
}
?>
showip.php
<html>
<head><title>show ip</title></head>
<body>
<table border="1" cellpadding="0" cellspacing="0" align="center" width="500">
<p><div align="center"><h2><strong>Show the visit ip</strong></h2></div></p>
<hr color="green" size="5" width="100%" /><br />
<tr><td>来访者IP</td><td>访问次数</td><td>访问时间</td></tr>
<?php
include_once "../datasource.inc.php";
include_once "../fy.php";
$sql="select * from rip";
genpage($sql,50);
$result=mysql_query($sql) or die($sql);
while($row=mysql_fetch_array($result))
{
echo "<div align='center'><tr><td width='150'>$row[ip]</td><td width='150'>$row[count]</td><td width='200'>$row[showdate]</td></tr></div>";
}
@showpage();
?>
<hr />
<?php
$query="select count(*) as allip from rip";
$result=mysql_query($query) or die($query);
$row=mysql_fetch_array($result);
echo "总共有"." ".$row["allip"]." "."个IP访问本网站";
?>
</table>
</body>
</html>
PHP Pagination Code
<?
//pagination function
function genpage(&$sql,$page_size=2)
{
global $prepage,$nextpage,$pages,$sums; //out param
$page = $_GET["page"];
$eachpage = $page_size;
$pagesql = strstr($sql," from ");
$pagesql = "select count(*) as ids ".$pagesql;
$result = mysql_query($pagesql) or die(mysql_error());
if($rs = mysql_fetch_array($result)) $sums = $rs[0];
$pages = ceil(($sums-0.5)/$eachpage)-1;
$pages = $pages>=0?$pages:0;
$prepage = ($page>0)?$page-1:0;
$nextpage = ($page<$pages)?$page+1:$pages;
$startpos = $page*$eachpage;
$sql .=" limit $startpos,$eachpage ";
}
//Show pagination
function showpage()
{
global $page,$pages,$prepage,$nextpage,$queryString; //param from genpage function
$shownum =10/2;
$startpage = ($page>=$shownum)?$page-$shownum:0;
$endpage = ($page+$shownum<=$pages)?$page+$shownum:$pages;
echo "All".($pages+1)."page: ";
if($page>0)echo "<a href=$PHP_SELF?action=holidays&page=0&$queryString>First</a>";
if($startpage>0)
echo " ... <b><a href=$PHP_SELF?page=".($page-$shownum*2)."&$queryString>«</a></b>";
for($i=$startpage;$i<=$endpage;$i++)
{
if($i==$page) echo " <b>[".($i+1)."]</b> ";
else echo " <a href=$PHP_SELF?action=holidays&page=$i&$queryString>".($i+1)."</a> ";
}
if($endpage<$pages)
echo "<b><a href=$PHP_SELF?action=holidays&page=".($page+$shownum*2)."&$queryString>»</a></b> ... ";
if($page<$pages)
echo "<a href=$PHP_SELF?action=holidays&page=$pages&$queryString>Last</a>";
}
?>
//show the pagination
include_once "fy.php";
$sql = " "; // sql
genpage($sql);
$result = mysql_query($sql);
while ( $row = mysql_fetch_array($result)) {}
showpage();

