php查询mysql的问题

来源:百度知道 编辑:UC知道 时间:2024/05/14 00:09:51
$reply_result = mysql_query("SELECT * FROM itigersbb_posts where topic_id =".$id." and id !=".$id );

我是想查某个帖子的回复,表itigersbb_posts存的是帖子数据,id是自动编号,topic_id表示是某帖的回复帖。但是表里把主帖的id和topic_id都存为相同的值

我现在从article.php?id=*获得某个主帖的id,如果我只查询where topic_id =".$id的话,会连同主帖一起查出来。我只想要回复帖怎么办呢? id !=".$id 不生效啊,是不是我写错了?

谢谢!

$reply_result = mysql_query ("SELECT * FROM itigersbb_posts where topic_id =".$id." and id !=".$id."");
或者
$reply_result = mysql_query ("SELECT * FROM itigersbb_posts where topic_id =$id and id !=$id");

但是表里把主帖的id和topic_id都存为相同的值,这句话是什么意思?

id !=".$id 应该写成 id!='$id'