评论者只能在他们的评论中删除评论选项

发布于 2024-12-15 17:25:13 字数 1629 浏览 1 评论 0原文

所以我有这个表和两个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰葑 2024-12-22 17:25:14

你不使用某种带有会话的登录系统,你可以在会话中存储用户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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文