我加載使用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>";
}
有了上面的代碼,對於每個評論我做了一個新的闕ry,這顯然是錯誤的,我應該如何加入第一個查詢?
謝謝
這不會加載任何評論product_id = 3 – behz4d
對不起,我已經更新了我上面的答案中的查詢 - 它現在起作用了,我自己測試了它。這是'WHERE'子句中的一個錯誤,因爲'reporter_user_id'可能並不總是可用的(所以它必須位於'ON'部分中)。希望它現在適合你,請讓我知道;) – Francodi
似乎有什麼不對勁,它只是加載1條評論,而對於product_id = 3有超過10條評論,而對於其他產品則不加載! – behz4d