我正在为 id = '3' 的产品加载评论
$get_comments = mysql_query("SELECT * FROM products_comments WHERE product_id = '3'");
现在我想为每条评论添加“报告滥用”选项,为此我有另一个表作为“ abuse_reports
”,用户滥用报告将存储在此表中,现在如果用户报告了评论,该report abuse
选项不应该在那里为该用户发表评论,为此我正在做:
while($row = mysql_fetch_array($get_comments)){
echo blah blah blah // comment details
// now for checking if this user should be able to report this or not, i make this query again:
$check_report_status = mysql_query("SELECT COUNT(id) FROM abuse_reports WHERE reporter_user_id = '$this_user_id' AND product_id = 'this_product_id'");
// blah blah count the abuse reports which the current user made for this product
if($count == 0) echo "<a>report abuse</a>";
}
使用上面的代码,对于每条评论,我都会进行一个新查询,这显然是错误的,我应该如何将第二个查询与第一个查询结合起来?
谢谢