落伍者站长论坛's Archiver

ALYAR 发表于 2008-5-25 08:14

一个关于sql语句的问题

我在用phpwind的论坛程序
我打算热门话题改成一下 改成到近10天内的点击数最多的。。
$query = $db->query("SELECT pt.tid,pt.author,pt.subject,pt.postdate,pt.hits FROM pw_threads pt LEFT JOIN pw_forums pf USING(fid) where pt.ifcheck='1' and ".$showforum." and pf.password = '' order by pt.hits desc limit 0,$listnum");

但是不知道where里怎么表达
asp中我用这个
AND DateDiff('d',[time],Now())<=10 order by hits desc
实现的  但是phpwind中 用这个就出错
希望兄弟们的帮忙

sinosoho 发表于 2008-5-25 09:08

我也不会啊 同来进修

zzstat 发表于 2008-5-25 09:42

如果贴子中时间存储用的是时间戳格式,可以这样写,省略前面:
$query = $db->query("WHERE 贴子中时间>".time()-10*86400." ORDER BY hits DESC");

ALYAR 发表于 2008-5-25 13:47

谢谢你  我去试一试

ALYAR 发表于 2008-5-25 13:47

谢谢你  我去试一试

ALYAR 发表于 2008-5-25 13:52

$query = $db->query("SELECT pt.tid,pt.author,pt.subject,pt.postdate,pt.hits FROM pw_threads pt LEFT JOIN pw_forums pf USING(fid) where pt.ifcheck='1' and ".$showforum." and pf.password = '' and  pt.postdate > ".time()-10*86400." order by pt.hits desc limit 0,$listnum");

这样改后除了这个错误

Parse error: parse error, unexpected '"' in e:\fxhost\alyar\web\bbs\template\wind\index.htm on line 30

ALYAR 发表于 2008-5-25 14:43

没有人知道吗?

zzstat 发表于 2008-5-25 14:57

".(time()-10*86400)."
加上括号

[[i] 本帖最后由 zzstat 于 2008-5-25 15:02 编辑 [/i]]

ALYAR 发表于 2008-5-25 15:34

谢谢您!
通过您的帮助已经解决这个问题了。

zzstat 发表于 2008-5-25 17:55

[quote]原帖由 [i]ALYAR[/i] 于 2008-5-25 15:34 发表 [url=http://www.im286.com/redirect.php?goto=findpost&pid=26451873&ptid=2607873][img]http://www.im286.com/images/common/back.gif[/img][/url]
谢谢您!
通过您的帮助已经解决这个问题了。 [/quote]

能帮助人很高兴。

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.