


This article will introduce you to an example of php+mysql article views statistics and release time. If you need this, feel free to refer to it.
A web page can display the "file upload time" and "number of viewers", which is not only a record of the article's history, but also reflects the article's popularity with the audience. There must be many ways to record "file upload time" and "number of viewers". The author wrote one using php+mysql based on my own understanding. I don't know if the code is optimized enough, but it feels good to use and there are no problems. I will write it down and share it with everyone. .
Thoughts
1. When uploading an article, first write the "webpage address", "upload time time()" and "counting starting point 0" in the database.
2. When the user opens the webpage, first use $_SESSION["article"] to determine whether it is online. If it is not online, open the database, take out the original count, add 1, and then update the database. Prevent online users from "refreshing" and inflating the count.
3. Open and take out the last updated count and display it on the web page.
Example
In front of write:
The code is as follows
|
Copy code
|
||||
$stsfile = "10001.php"; $nowtime = time(); date_default_timezone_set("Asia/Chongqing");//Set the time standard If (!isset($_SESSION['article']) || $_SESSION['article'] != $stsfile ) //Determine whether the user is online { $link = mysql_connect("localhost","library name","password") or die ("Failed to open database"); mysql_select_db("Library name",$link); //Connect to database mysql_query("set names 'utf8'"); //Set access encoding |
mysql_query("INSERT INTO `statistics`(`StsFile`,`StsTime`,`StsNumb`) VALUES ('$stsfile','$nowtime','0')");
session_start();
$_SESSION['article'] = $stsfile;
}
Else
{
$numb = $row['StsNumb']+1;
mysql_query("UPDATE `statistics` SET `StsNumb` = '$numb' WHERE `StsFile` = '$stsfile'");
session_start();
$_SESSION['article'] = $stsfile; //Write $_SESSION[]
}
}
?>

一、今日头条发布文章怎么才能有收益?今日头条发布文章获得更多收益方法!1.开通基础权益:原创文章选择投放广告可获得收益,视频必须要原创横屏才会有收益。2.开通百粉权益:粉丝量达到百粉以上,微头条、原创问答创作及问答均可获得收益。3.坚持原创作品:原创作品包含文章、微头条及问题等,要求300字以上。注意违规抄袭作品作为原创发布,会被扣信用分,即使有收益也会被扣除。4.垂直度:做专业领域一类的文章,不能随意跨领域写文章,会得不到合适的推荐,达不到作品的专和精,难以吸引粉丝读者。5.活跃度:活跃度高,

如何在uniapp中实现数据统计和分析一、背景介绍数据统计和分析是移动应用开发过程中非常重要的一环,通过对用户行为的统计和分析,开发者可以深入了解用户的喜好和使用习惯,从而优化产品设计和用户体验。本文将介绍如何在uniapp中实现数据统计和分析的功能,并提供一些具体的代码示例。二、选择合适的数据统计和分析工具在uniapp中实现数据统计和分析的第一步是选择合

Vue框架下,如何快速搭建统计图表系统在现代网页应用中,统计图表是必不可少的组成部分。Vue.js作为一款流行的前端框架,提供了很多便捷的工具和组件,能够帮助我们快速搭建统计图表系统。本文将介绍如何利用Vue框架以及一些插件来搭建一个简单的统计图表系统。首先,我们需要准备一个Vue.js的开发环境,包括安装Vue脚手架以及一些相关的插件。在命令行中执行以下命

Vue统计图表的线性、饼状图功能实现在数据分析和可视化领域,统计图表是一种非常常用的工具。Vue作为一种流行的JavaScript框架,提供了便捷的方法来实现各种功能,包括统计图表的展示和交互。本文将介绍如何使用Vue来实现线性和饼状图功能,并提供相应的代码示例。线性图功能实现线性图是一种用于展示数据趋势和变化的图表类型。在Vue中,我们可以使用一些优秀的第

如何使用MySQL的COUNT函数统计数据表的行数在MySQL中,COUNT函数是一个非常强大的函数,用于统计数据表中满足特定条件的行数。本文将介绍如何使用MySQL的COUNT函数来统计数据表的行数,并提供相关的代码示例。COUNT函数的语法如下:SELECTCOUNT(column_name)FROMtable_nameWHEREconditi

随着互联网的快速发展,Web应用程序的使用越来越普遍,如何对Web应用程序的使用情况进行监控和分析成为了开发者和网站经营者的关注点。GoogleAnalytics是一种强大的网站分析工具,可以对网站访问者的行为进行跟踪和分析。本文将介绍如何在Beego中使用GoogleAnalytics来统计网站数据。一、注册GoogleAnalytics账号首先需要

苹果的iPhone电池,因为用户经常使用的关系,因此损耗是比一般电子产品更快,而一般的iPhone电池设计,是可以在日常生活中,循环充电500次,仍然有原效能的80%容量,但如何才能知道你iPhone的电池充电次数?首先进入设定,一般关于本机最低有电池,就可以看到


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
