我想在我的网站上显示排名前 10 的种子种子,但要根据点击次数(浏览次数)和添加日期来显示。
这是我正在使用的代码,该代码显示了前 10 个种子最多的种子。但我想显示过去 24 小时内种子最多的 10 种种子。上传 24 小时的 torrent 后。它应该被最近 24 小时内下一个种子最多的 torrent 替换。
$movie = "
SELECT t.id
, t.anon
, t.announce
, t.category
, t.leechers
, t.nfo
, t.seeders
, t.name
, t.times_completed
, t.size
, t.added
, t.comments
, t.numfiles
, t.filename
, t.owner
, t.external
, t.freeleech
, c.name AS cat_name
, c.image AS cat_pic
, c.parent_cat AS cat_parent
, u.username
, u.privacy
, IF(t.numratings < 2, NULL, ROUND(t.ratingsum / t.numratings,1)) rating
FROM torrents t
LEFT
JOIN categories c
ON c.id = t.category
LEFT
JOIN users u
ON u.id = t.owner
WHERE visible = 'yes'
AND banned = 'no'
AND c.parent_cat = 'Movie'
ORDER
BY t.seeders + t.leechers + t.hits DESC
, t.seeders DESC
, t.added DESC
LIMIT 10
";
请解决这个问题,我从上个月开始就试图解决这个问题。或者如果可能的话,过去 24 小时内观看次数最多的 Torrent 应显示在顶部。
最佳答案
您的 torrent 表架构是什么?
是torrents.added DATETIME 列还是unix 时间戳的常规INT?
$movie = "
SELECT t.id
, t.anon
, t.announce
, t.category
, t.leechers
, t.nfo
, t.seeders
, t.name
, t.times_completed
, t.size
, t.added
, t.comments
, t.numfiles
, t.filename
, t.owner
, t.external
, t.freeleech
, c.name AS cat_name
, c.image AS cat_pic
, c.parent_cat AS cat_parent
, u.username
, u.privacy
, IF(t.numratings < 2, NULL, ROUND(t.ratingsum / t.numratings,1)) rating
FROM torrents t
LEFT
JOIN categories c
ON c.id = t.category
LEFT
JOIN users u
ON u.id = t.owner
WHERE visible = 'yes'
AND banned = 'no'
AND c.parent_cat = 'Movie'
AND t.added > DATE_SUB(NOW(), INTERVAL 1 DAY)
ORDER
BY t.seeders + t.leechers + t.hits DESC
, t.seeders DESC
, t.added DESC
LIMIT 10
";
关于php - 如何显示浏览量最多的前10名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23290609/