[英]Counting amount of db rows of a user using timestamp - Best approach?
This might sound quite stupid, but whats the best approach to count a users db entries of today, so I can publish the most activate member with mysqli? 这听起来可能很愚蠢,但是今天计算用户数据库条目的最佳方法是什么,那么我可以使用mysqli发布最活跃的成员吗?
Thanks.. 谢谢..
Edited; 编辑; Current code
当前代码
$promote_amount_posts = mysqli_query($mysqli,"SELECT COUNT(rec_by_id) FROM posts LIMIT 1 ");
$row = mysqli_fetch_assoc($promote_amount_posts);
$promote_amount_posts = $row['COUNT(rec_by_id)'];
$most_active_user_id = $row['rec_by_id'];
Lets say my user_id (which goes into the rec_by_id column) is 82392 and I created 20 posts. 假设我的user_id(进入rec_by_id列)为82392,我创建了20个帖子。 There should be atlease MY 20 posts in the 'posts' table.
“职位”表中应至少有MY 20职位。 How do I fetch my user_id so I can echo it anywhere?
如何获取我的user_id,以便可以在任何地方回显它?
The following query should return the count in today_db_entries
as long as you have a created
column and a id
column - swap out those names for whatever your schema uses. 只要您有一个
created
列和一个id
列,以下查询应在today_db_entries
返回计数-将那些名称换成您的模式使用的名称。
SELECT COUNT(id) as today_db_entries
FROM table
WHERE created BETWEEN getdate() AND getdate()-1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.