$sql = "select * from dede_tongji where sourceUrl='$sourceUrl' and aimUrl='$aimUrl' and date='$time'";
$res = $db->query($sql); www.2cto.com
//First check whether there is data for this link in the current database on this day. If not, create it. Otherwise, use the cookie value to determine how much the IP and Pv have increased respectively.
if ( $row = $res->fetch_assoc() ){
$pvSum = $row['pvSum'] + 1;
if( $_COOKIE['iptag'] == $cookieTag ){
$sql = "update dede_tongji set pvSum = '$pvSum' where sourceUrl='$sourceUrl' and aimUrl='$aimUrl' and date='$time' ";
$db->query($sql);
//Otherwise just ip and pv increase by one
}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);
} }
}else{
//If there is no data in the database, add a new piece of data
$sql = "insert into dede_tongji (sourceUrl,aimUrl,ipSum,pvSum,date) values ('$sourceUrl','$aimUrl',1,1,'$time')";
if( $db->query($sql)){
}else{
$db->error;
} }
}
//Use js to achieve jump
echo "";
?>
Querying from the database, a paging class is used here. You can find it in my Lingyiyi blog. The usage of this paging class can be well understood by combining this example and the member functions of the paging class. It is mainly in progress. When querying the database, just add limit conditions to the sql statement. The paging class used is: page.class.php
The following is the use of querying front-end display data and paging classes from the database, as well as some js for controlling dates
echo " Please choose to jump to page: ";echo $pageList->selectList().';
}
?>
Finally, there is the structure of the database table, so that there is only one table with some small errors in the pv record, because the time here is mainly controlled by cookies, so there are errors. If there are experts, you can optimize the database design and use IP to Control, limited ability, please forgive me:
CREATE TABLE `dede_tongji` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `sourceUrl` varchar(255) NOT NULL, `aimUrl` varchar(255) NOT NULL, `ipSum` int(10) unsigned NOT NULL, `pvSum` int(10) unsigned NOT NULL, `date` date NOT NULL,
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn