Deposit Database: Connect_errno) {die (' Database connection failed: '. $mysqli->connect_error);} $db->query (' Set names UTF8 '); $sql = "SELECT * from Dede_tongji where sourceurl= ' $sourceUrl ' and aimurl= ' $aimUrl ' and date= ' $time '"; $res = $db->query ($sql); Www.2cto.com//First look at the current database this day there is no data on this link, if not created, otherwise according to the cookie value, to determine how much IP and PV increase respectively. if ($row = $res->fetch_assoc ()) {$pvSum = $row [' pvsum '] + 1; if ($_cookie[' iptag ' = = = $cookieTag) {$sql = "update de De_tongji Set pvsum = ' $pvSum ' where sourceurl= ' $sourceUrl ' and aimurl= ' $aimUrl ' and date= ' $time ' "; $db->query ($sql); Otherwise just IP and PV add a}else{$ipSum = $row [' ipSum '] + 1; $sql = "Update Dede_tongji set ipSum = ' $ipSum ', pvsum = ' $pvSum ' where Sourceurl= ' $sourceUrl ' and aimurl= ' $aimUrl ' and date= ' $time ' "; $db->query ($sql); A new data is added to the}else{///Database $sql = "INSERT into Dede_tongji (sourceurl,aimurl,ipsum,pvsum,date) VALUES (' $sourceUrl ', ' $ Aimurl ', the ' $time '); if ($db->query ($sql)) {}else{$db->error;}} Use JS to achieve jump echo "";?> query from the database, here used to a paging class in my make a blog everyoneCan be found, about the usage of this page class combined with this example and the member function of the pagination class can be well understood, mainly in the database query when the SQL statement with limit conditions on it can be, The paging class used is: page.class.php The following is the use of querying the foreground display data and paging classes from the database, and some control-date JS '; Echo $date; Exit (); Connect database $db = new mysqli (' localhost ', ' a ', ' Acyr ', ' www_a_com '); if ($mysqli->connect_errno) {die (' Database connection failed: '. $mysqli->connect_error);} $db->query (' Set names UTF8 '); If the query date is now the current date, then all output and sort by date if ($date = = $time) {//Get the total number of bars in this case for pagination display (this parameter is used for the paging class) $sql = "SELECT count (*) from Dede_ Tongji where sourceurl= ' $wangzhan ' ORDER by date desc '; $row = $db->query ($sql)->fetch_row (); $allRows = $row [0]; Total number of bars $pageList = new page ($allRows, 2,4,array (' pre ' + = ' prev ', ' next ' = ' next ')); $res = $db->query ("select * from Dede_tongji where sourceurl= ' $wangzhan ' ORDER by date desc {$pageList->limit ()}" ); $sql = "SELECT * from Dede_tongji where sourceurl= ' $wangzhan ' ORDER by date desc {$pageList->limit ()}"; Echo $sql; $res = $db->query ($sql); $RESARR = Array (); while ($row = $res->fetch_assoc ()) {$RESARR [] = $row;} $res->free_result (); /*echo '
'; Var_dump ($RESARR); foreach ($resArr as $v) {echo $v [' Aimurl ']; }*///print_r ($res); Exit (); }else{//Gets the total number of bars in this case, for pagination display $sql = "SELECT count (*) from Dede_tongji where sourceurl= ' $wangzhan ' and Dat E= ' $date ' "; $row = $db->query ($sql)->fetch_row (); $allRows = $row [0]; Total number of bars $pageList = new page ($allRows, 2,4,array (' pre ' + = ' prev ', ' next ' = ' next ')); $sql = "SELECT * from Dede_tongji where sourceurl= ' $wangzhan ' and date= ' $date ' {$pageList->limit ()}"; Echo $sql; $res = $db->query ($sql); $RESARR = Array (); while ($row = $res->fetch_assoc ()) {$RESARR [] = $row; } $res->free_result (); Print_r ($res); Exit (); }?>
<title>Statistical results</title>
statistics website
outbound connections |
ip (standalone) |
PV |
date |
!--? php foreach ($resArr as $v) {?-->
|
"!--? php}?--"
Pre (); echo $pageList->first (); Echo $pageList->strlist (); echo $pageList->end (); Echo $pageList->next (); echo "Please select Jump to:"; Echo $pageList->selectlist (). ' Page '; }?> Finally there is the structure of the database table, so that only a table in the PV record there are some small errors, because here is mainly controlled by the cookie time, so there is an error if a master can optimize the database design with IP to control, limited capacity, hope we forgive: CREATE TABLE ' Dede_ Tongji ' (' id ' int () unsigned not null auto_increment, ' sourceurl ' varchar (255) isn't null, ' aimurl ' varchar (255) NOT NULL , ' ipSum ' int (ten) unsigned NOT NULL, ' pvsum ' int (ten) unsigned not NULL, ' date ' date is not NULL,
http://www.bkjia.com/PHPjc/477856.html www.bkjia.com true http://www.bkjia.com/PHPjc/477856.html techarticle Deposit Database: PHP header (content-type:text/html; charset=utf-8);//echo $_cookie[iptag]; Date_default_timezone_set (PRC ); Destination site URL $aimUrl = $_get[r]; SOURCE website ...