Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

php - Have a delete button exaclty where I want it

and it's linked to a 'confirm comment deleted page. Ideally I would like it to just become erased and have the page reload with it gone, and then send it to my db marked as dead.

Basically, users have a profile which allows other users to make comments.With the help of PHP I would like to be able to have the delete button only show up when a users is looking at their profile.

This is what I have so far:

$query = "SELECT * FROM `ProfileComments` WHERE `ToUserID` = '".$prof->id."' ORDER BY `date` DESC, `time` DESC LIMIT 10";

$request = mysql_query($query,$connection);

while($result = mysql_fetch_array($request)) {

    $poster = new User($result['FromUserID']);

    echo "<div id='CommentProfile'>";
    echo "<div id='CommentPhotoProfile'>";
    echo "<a href='http://www.blahblah.org/Profile.php?id=".$poster->id."'>";
    echo "<img src='" . $poster->img('mini') . "' border='0'/>";
    echo "</a>";
    echo "</div>";
    echo "<div id='ProfileCommentBody' class= 'round_10px'>";
    echo "<div id='CommentNameProfile'>";
    echo "<div class='ProfileCommentTail'>&nbsp;</div>";
    echo "<a href='http://www.blahblah.org/Profile.php?id=".$poster->id."'>";
    echo $poster->first_name. " ". $poster->last_name. " <span style='font-weight:normal'>says...</span>";
    echo "</a>";
    echo "</div>";
    echo stripslashes(nl2br($result['commentProfileBody']));
    echo "<div id='CommentInfoProfile'>";
    echo date('M d, Y',strtotime($result['date']));
    echo " at " . date('g:i A',strtotime($result['time']));
    if ($prof->id == $prof->id)
        echo "<a href='http://www.blahblah.org/DeleteComment.php?id=".$prof->id."'>";
    echo " delete";
    echo "</a>";
    echo "</div>";
    echo "</div>";
    echo "</div>";
}
?>

I have asked this question a couple of times today and either gotten vague answers(which is partly my fault because I did not give enough example code which hopefully the above is enough) or I have gotten talked down to,questioned about my ability or told to go hire a developer. haha. So if you are a more experienced developer who wants to share their knowlege with an up and coming developer that would be GREATLY appreciated. Afterall is that not one of the purposes of this site?

If you don't have the time to explain this to me, a link to a great tutorial or resource that can help me find my way would be amazing! thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try changing the line:

if ($prof->id == $prof->id)

to

if ($poster->id == $prof->id)

so that the delete link only shows up when the profile belongs to the poster.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...