Home > Backend Development > PHP Tutorial > PHP logic is dead! Deletion guidelines for comments

PHP logic is dead! Deletion guidelines for comments

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-09-06 08:57:11
Original
1365 people have browsed it

<code><? if($row['id']==$_SESSION['id']){?>
                            <? if($com['id']==$_SESSION['id']){?>
                            
                            <button id="remove_<? echo $com['comment_id'];?>">
                            刪除
                            </button>

                            <? }?>
                        <? }?>
</code>
Copy after login
Copy after login

The above is my program code
comment_id is the ID automatically generated after leaving a message
com['id'] is the ID left by the user after leaving a message
SESSION['id'] is the user's own ID (you will get it when you log in )
row['id'] is the ID automatically generated by the user who published the article
The user himself can leave a message in the "own article"
Other users can also leave a message in the "own article"

So I got stuck

If it is written like this

<code><? if($com['id']==$_SESSION['id']){?>
                            <div style="position:absolute; right:0; top:0;" id="show_remove_<? echo $row['timeline_id'];?>">
                            
                            <button id="remove_<? echo $com['comment_id'];?>" class="n2">
                            <i style="color:#ccc; font-size:15px;" class="material-icons">delete_forever</i>
                            </button>
                            
                            </div>
                        <? }?>
</code>
Copy after login
Copy after login

If you write like this, when the user (or others) reads your own article, the user's own message will be displayed as "Delete"

<code><? if($row['id']==$_SESSION['id']){?>
                            
                            <div style="position:absolute; right:0; top:0;" id="show_remove_<? echo $row['timeline_id'];?>">
                            
                            <button id="remove_<? echo $com['comment_id'];?>" class="n2">
                            <i style="color:#ccc; font-size:15px;" class="material-icons">delete_forever</i>
                            </button>
                            
                            </div>
                            
                        <? }?>
</code>
Copy after login
Copy after login

If you write like this, when you read your own article, all comments will be displayed as "Delete"
But when others read your article, nothing will be displayed

The purpose I want is to **if the article is posted by myself
so the comments below can be displayed as "Delete" whether it is yourself or someone else
But when others read your article, their own comments will be displayed as "Delete"* *

Logic is dead...Help me handsome guys and beauties!

Reply content:

<code><? if($row['id']==$_SESSION['id']){?>
                            <? if($com['id']==$_SESSION['id']){?>
                            
                            <button id="remove_<? echo $com['comment_id'];?>">
                            刪除
                            </button>

                            <? }?>
                        <? }?>
</code>
Copy after login
Copy after login

The above is my program code
comment_id is the ID automatically generated after leaving a message
com['id'] is the ID left by the user after leaving a message
SESSION['id'] is the user's own ID (you will get it when you log in )
row['id'] is the ID automatically generated by the user who published the article
The user himself can leave a message in the "own article"
Other users can also leave a message in the "own article"

So I got stuck

If you write it like this

<code><? if($com['id']==$_SESSION['id']){?>
                            <div style="position:absolute; right:0; top:0;" id="show_remove_<? echo $row['timeline_id'];?>">
                            
                            <button id="remove_<? echo $com['comment_id'];?>" class="n2">
                            <i style="color:#ccc; font-size:15px;" class="material-icons">delete_forever</i>
                            </button>
                            
                            </div>
                        <? }?>
</code>
Copy after login
Copy after login

If you write like this, when the user (or others) reads your own article, the user's own message will be displayed as "Delete"

<code><? if($row['id']==$_SESSION['id']){?>
                            
                            <div style="position:absolute; right:0; top:0;" id="show_remove_<? echo $row['timeline_id'];?>">
                            
                            <button id="remove_<? echo $com['comment_id'];?>" class="n2">
                            <i style="color:#ccc; font-size:15px;" class="material-icons">delete_forever</i>
                            </button>
                            
                            </div>
                            
                        <? }?>
</code>
Copy after login
Copy after login

If you write like this, when you read your own article, all comments will be displayed as "Delete"
But when others read your article, nothing will be displayed

The purpose I want is to **if the article is posted by myself
so the comments below can be displayed as "Delete" whether it is yourself or someone else
But when others read your article, their own comments will be displayed as "Delete"* *

Logic is dead...Help me handsome guys and beauties!

Can’t you just add a relationship of ||?

<code><? if ($com['id'] == $_SESSION['id'] || $row['id'] == $_SESSION['id']) { ?>
    <div style="position:absolute; right:0; top:0;" id="show_remove_<? echo $row['timeline_id'];?>">
        <button id="remove_<? echo $com['comment_id'];?>" class="n2">
            <i style="color:#ccc; font-size:15px;" class="material-icons">delete_forever</i>
        </button>
    </div>
<? }?></code>
Copy after login
Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template