在我想要的地方有一个删除按钮 [英] Have a delete button exaclty where I want it

查看:71
本文介绍了在我想要的地方有一个删除按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它与确认评论已删除页面相关联。理想情况下,我希望它只是被删除,并使页面重新加载,然后将其发送到我的db标记为已死。

基本上,用户有一个允许其他用户发表评论的配置文件。在PHP的帮助下,我希望能够让删除按钮仅在用户正在查看他们的个人资料。



这是我到目前为止:

  $ 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'/>;
回声< / a>;
回显< / 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。 。 $生成海报>姓氏。 < span style ='font-weight:normal'>说...< / span>;
回声< / a>;
回显< / div>;
echo stripslashes(nl2br($ result ['commentProfileBody']));
echo< div id ='CommentInfoProfile'>;
回音日期('M d,Y',strtotime($ result ['date']));
echoat。 date('g:i A',strtotime($ result ['time']));
if($ prof-> id == $ prof-> id)
echo< a href ='http://www.blahblah.org/DeleteComment.php?id = 。$ prof-> ID > 中;
echodelete;
回声< / a>;
回显< / div>;
回显< / div>;
回显< / div>;
}
?>

今天我问了这个问题几次,要么得到模糊的答案(这部分是我的错因为我没有提供足够的示例代码,希望上面的内容已经足够了)或者我已经被讨论过,质疑我的能力或被告知要雇用开发人员。哈哈。因此,如果您是一位更有经验的开发人员,他希望与即将到来的开发人员分享他们的知识,他们将非常感谢。毕竟这不是这个网站的目的之一吗?



如果你没有时间向我解释这个,那就是指向一个很棒的教程或资源的链接可以帮助我找到自己的方式将是惊人的!谢谢。

解决方案

尝试换行:

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





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

以便删除链接仅在个人资料属于海报时显示。


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.

解决方案

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.

这篇关于在我想要的地方有一个删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆