search
HomeBackend DevelopmentPHP TutorialWeekly ranking and monthly ranking development summary (original)_PHP tutorial
Weekly ranking and monthly ranking development summary (original)_PHP tutorialJul 13, 2016 pm 05:42 PM
mysqlweekfunctionOriginalweekdevelopSummarizerankingRanking listmoonKnowledge

Preliminary knowledge: group by, MYSQL functions week(), month()

When designing a database, there is usually a field to record the click-through rate of an article. If we want to calculate the click-through rate ranking for a week or a month, it is definitely impossible to achieve it by relying on this field alone. At this time, a new table will be created to record the daily click-through rate of each article.
Assume that this table is named ranking, and four fields are defined: rid (table ID), contentid (associated with article ID), hits (records daily click-through rate), date (time, important, compared during query)
Rough structure of ranking
id contentid hits dates
1 2 12 2010-12-18
2 2 2 23 2010-12-19
3 1 15 2010-12-19
4 2 21 2010-12-20
1. Statistics
The first step is to record the daily click-through rate of the article. This step is very simple. When the user views an article, the PHP program will perform a database query to determine whether the record exists. If it does not exist, it means that it is that day. When browsing the article for the first time, a record needs to be inserted. When subsequent visitors read the article again, they only need to update the click-through rate. This is to record the click-through rate of a certain article for a day.
PHP:
$date = date("Y-m-d",time());
$contentid = $_GET[id];//Current article ID
$query = mysql_query("select * from ranking where contentid=$contentid and date=$date); //Query database
if($value = mysql_fetch_array($query)){
mysql_query("update ranking set hits = hits+1 where id=$value[id] ");//If there is a record, just click rate +1
}else{
mysql_query("insert into ranking (`contentid`,`hits`,`date`) values($contentid,1,$date)");//If it is the first time browsing, insert a piece of data, click rate is 1
}
2. Inquiry
At this point, the statistical work has been completed. Next, it is difficult to query these articles in order of the total click rate for a week or a month.
1. First group the articles and calculate the total click rate: select *,sum(hits) from ranking group by contentid order by sum(hits) desc
2. Take this week’s data and filter it out: select *,sum(hits) from ranking where week(date)=week(now()) group by contentid order by sum(hits) desc
This is the query statement for weekly ranking. It is relatively complicated. After querying, it is put into an array and displayed sequentially. The same is true for monthly ranking. Just change the function. I will not write the complete PHP code.
http://bbs.2cto.com/mode.php?m=o&q=user&u=53700

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486038.htmlTechArticlePreliminary knowledge: group by, MYSQL functions week(), month() generally have a field when designing a database To record the click-through rate of the article, if we want to count the click-through rate ranking for a week or a month...
Statement
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
2023年最新显卡性能排名列表2023年最新显卡性能排名列表Jan 05, 2024 pm 11:12 PM

2023最新显卡跑分排行榜已经发布,关注显卡天梯图的用户们都可以来看看,最近随着显卡厂商不断的发布新显卡,甚至还有老系列的推陈出新,新的榜单已经完全不一样了~2023最新显卡跑分排行榜显卡天梯排行2023年电脑显卡选购建议:1、低端显卡:RTX3050、5600XT、2060S都是不错的入门之选相当于买显卡送CPU,可用于玩LOL、Cf、守望先锋等轻量级3D网游,性价比突出,2、入门显卡:3060,适合多数一般的主流3D游戏,中低画质吃鸡。3、中端显卡:NVIDIA:RTX3060Ti、RTX2

我创建了一个由 ChatGPT API 提供支持的语音聊天机器人,方法请收下我创建了一个由 ChatGPT API 提供支持的语音聊天机器人,方法请收下Apr 07, 2023 pm 11:01 PM

今天这篇文章的重点是使用 ChatGPT API 创建私人语音 Chatbot Web 应用程序。目的是探索和发现人工智能的更多潜在用例和商业机会。我将逐步指导您完成开发过程,以确保您理解并可以复制自己的过程。为什么需要不是每个人都欢迎基于打字的服务,想象一下仍在学习写作技巧的孩子或无法在屏幕上正确看到单词的老年人。基于语音的 AI Chatbot 是解决这个问题的方法,就像它如何帮助我的孩子要求他的语音 Chatbot 给他读睡前故事一样。鉴于现有可用的助手选项,例如,苹果的 Siri 和亚马

2024年最佳流畅性能的Win11版本排行2024年最佳流畅性能的Win11版本排行Jan 08, 2024 pm 04:53 PM

Windows11是微软最新的操作系统版本,它带来了全新的界面和许多增强功能。在Windows11中,有几个版本被认为是运行最流畅的。其中包括Windows11Home和Windows11Pro。这些版本经过优化,能够提供更好的性能和稳定性,在各种计算机配置下都能够流畅运行。它们提供了广泛的功能和工具,如浏览器、邮件、办公套件等,同时支持个性化设置,以满足用户的需求。win11运行最流畅的版本有哪些1、Windows11系统旗舰版(点击下载)其丰富多彩且别有心思的圆角设计令此作品既优雅又显庄重,

摔倒检测-完全用ChatGPT开发,分享如何正确地向ChatGPT提问摔倒检测-完全用ChatGPT开发,分享如何正确地向ChatGPT提问Apr 07, 2023 pm 03:06 PM

哈喽,大家好。之前给大家分享过摔倒识别、打架识别​,今天以摔倒识别​为例,我们看看能不能完全交给ChatGPT来做。让ChatGPT​来做这件事,最核心的是如何向ChatGPT​提问,把问题一股脑的直接丢给ChatGPT​,如:用 Python 写个摔倒检测代码 是不可取的, 而是要像挤牙膏一样,一点一点引导ChatGPT​得到准确的答案,从而才能真正让ChatGPT提高我们解决问题的效率。今天分享的摔倒识别​案例,与ChatGPT​对话的思路清晰,代码可用度高,按照GPT​返回的结果完全可以开

PHP实现热门排行功能PHP实现热门排行功能Jun 23, 2023 am 11:32 AM

随着互联网的快速发展,网站所面对的用户数量也在不断增长。对于大型的网站来说,如何实现热门排行功能是一个非常重要的问题。热门排行可以让用户方便地查看当前最受欢迎的内容,同时也可以为网站的推广和流量增长带来很大的帮助。本文将介绍如何使用PHP实现热门排行功能。确定热门排行的指标在实现热门排行功能之前,我们需要先确定热门排行的指标。指标可以是点击次数、浏览量、收藏

UC伯克利LLM准中文排行榜来了!GPT-4稳居第一,国人开源RNN模型冲进前六UC伯克利LLM准中文排行榜来了!GPT-4稳居第一,国人开源RNN模型冲进前六May 16, 2023 pm 10:43 PM

前段时间,来自LMSYSOrg(UC伯克利主导)的研究人员搞了个大新闻——大语言模型版排位赛!这次,团队不仅带来了4位新玩家,而且还有一个(准)中文排行榜。OpenAIGPT-4OpenAIGPT-3.5-turboAnthropicClaude-v1RWKV-4-Raven-14B(开源)毫无疑问,只要GPT-4参战,必定是稳居第一。不过,出乎意料的是,Claude不仅超过了把OpenAI带上神坛的GPT-3.5位列第二,而且只比GPT-4差了50分。相比之下,排名第三的GPT-3.5只比13

AIRankings世界高校AI排行榜出炉AIRankings世界高校AI排行榜出炉Apr 09, 2023 pm 07:21 PM

又是一年高考季。记得当年小编高考的时候,还流行这么一句话。那就是,「本科看学校,读研看专业」。这话放之前可能确实没什么错。然而,随着近几年科技突飞猛进的发展,一些和前端科技挂钩的专业可能就要从本科开始起步了。要说当下最火的专业,莫过于人工智能了。恰好最近AIRankings发布了一份全球大学AI相关专业排行榜。让我们一起看看有哪些大学和机构榜上有名吧。AI世界排名:北清综合前三AIRankings排名综合过去十年的研究,以及通用人工智能、计算机视觉、机器人、机器学习、自然语言处理、认知推理、多智

2020年amd显卡性能排名2020年amd显卡性能排名Jan 13, 2024 pm 08:54 PM

amd图形显卡排行1、Radeon需要重新写作的内容是:RX需要重新写作的内容是:6950XT2、Radeon需要重新写作的内容是:RX需要重新写作的内容是:6900XT需要重写的是:3、Radeon需要重新写作的内容是:RX需要重新写作的内容是:6800XT4、Radeon需要重新写作的内容是:RX需要重新写作的内容是:6800需要重写的是:5、Radeon需要重新写作的内容是:RX需要重新写作的内容是:6750XT6、Radeon需要重新写作的内容是:RX需要重新写作的内容是:6700XT7

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!