Php Commentor仅在其注释上获取删除注释选项
我有这个表和两条sql语句。我想在第一个查询中为commentor 3提供使用$CommentorProfOwnerOpts删除注释的功能,该功能出现在从第二个查询中拉出的注释部分中 现在发生的事情是,commentor 2还获得$CommentorProfOwnerOpts,而只有commentor 3应该获得它们,并且只在它们的评论上 comment_id | comment_title | commentor_id | profile_owner_id ------------------------------------------------------------- 4 Title 1 2 1 5 Title 2 3 1 以下是评论:Php Commentor仅在其注释上获取删除注释选项,php,mysql,select,comments,Php,Mysql,Select,Comments,我有这个表和两条sql语句。我想在第一个查询中为commentor 3提供使用$CommentorProfOwnerOpts删除注释的功能,该功能出现在从第二个查询中拉出的注释部分中 现在发生的事情是,commentor 2还获得$CommentorProfOwnerOpts,而只有commentor 3应该获得它们,并且只在它们的评论上 comment_id | comment_title | commentor_id | profile_owner_id ------------------
//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,只在他们自己的评论中出现,而不在其他评论中出现。我如何解决这个问题?您是否使用了某种会话登录系统,您可以在会话中存储用户id
如果你不这样做,那么我建议你这样做,否则很难达到你想要的效果那么,如果$_SESSION['id']=$row['commentor\u id']{$CommentorProfOwnerOpts='Remove Comment';}仍然可以让commentor 3在所有其他评论上使用Remove选项,不仅仅是他们的:你不要在你的mysql查询中选择注释者id,从profile\u owner\u id=1的注释中选择注释者id、注释标题、注释者id
//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>'
}