评论者只能在他们的评论中删除评论选项
所以我有这个表和两个sql语句。我想为第一个查询中的评论者 3 提供使用 $CommentorProfOwnerOpts 删除其评论的能力,该功能出现在从第二个查询中拉出的评论部分中。
现在发生的情况是,评论者 2 也获得了 $CommentorProfOwnerOpts,而只有评论者 3 应该获得它们,并且只能在他们的评论中获得。
comment_id | comment_title | commentor_id | profile_owner_id ------------------------------------------------------------- 4 Title 1 2 1 5 Title 2 3 1
//Commentor 3
$commentor = mysql_query("SELECT commentor_id, comment_id FROM comments WHERE commentor_id=3 AND profile_owner_id=1");
$count = mysql_num_rows($commentor);
if ($count > 0) {
while($row = mysql_fetch_array($commentor)){
$commID = $row["comment_id"];
$CommentorProfOwnerOpts = '<span id="remove-'.$commID.'">Remove Comment</span>';
}
以下是评论:
//All Comments for profile owner 1
$comments = mysql_query("SELECT comment_id, comment_title FROM comments WHERE profile_owner_id=1");
while($row = mysql_fetch_array($comments)){
$comment_id = $row["comment_id"];
$comment_title = $row["comment_title"];
$CommentorProfOwnerOpts = '<span id="remove-'.$comment_ID.'">Remove Comment</span>';
$comments .= '<div id="$comment_id" class="comments">
'.$comment_title.'
'.$CommentorProfOwnerOpts.'
</div>'
}
问题是我无法弄清楚如何让每个评论者获得删除选项 $CommentorProfOwnerOpts
,仅出现在他们自己的评论中,而不出现在其他评论中。我该如何解决这个问题?
So I have this table and two sql statements. I want to give commentor 3 from the first query, the ability to remove their comment by using $CommentorProfOwnerOpts, which appears in the comments part being pulled out from the second query.
What happens now is that commentor 2 also gets the $CommentorProfOwnerOpts, when only commentor 3 should get them and ONLY on their comment.
comment_id | comment_title | commentor_id | profile_owner_id ------------------------------------------------------------- 4 Title 1 2 1 5 Title 2 3 1
//Commentor 3
$commentor = mysql_query("SELECT commentor_id, comment_id FROM comments WHERE commentor_id=3 AND profile_owner_id=1");
$count = mysql_num_rows($commentor);
if ($count > 0) {
while($row = mysql_fetch_array($commentor)){
$commID = $row["comment_id"];
$CommentorProfOwnerOpts = '<span id="remove-'.$commID.'">Remove Comment</span>';
}
And here are the comments:
//All Comments for profile owner 1
$comments = mysql_query("SELECT comment_id, comment_title FROM comments WHERE profile_owner_id=1");
while($row = mysql_fetch_array($comments)){
$comment_id = $row["comment_id"];
$comment_title = $row["comment_title"];
$CommentorProfOwnerOpts = '<span id="remove-'.$comment_ID.'">Remove Comment</span>';
$comments .= '<div id="$comment_id" class="comments">
'.$comment_title.'
'.$CommentorProfOwnerOpts.'
</div>'
}
The issue is that I can't figure out how to have each commentor get the remove option $CommentorProfOwnerOpts
, appear only for their own comment, and not on another comment. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不使用某种带有会话的登录系统,你可以在会话中存储用户ID吗?
如果你不这样做,那么我建议你这样做,否则将很难实现你想要的
dont you use some kind of login system with sessions where u can store the users id in the session?
if u dont then i advise you do orelse it will be very dificult to achieve what u want