doufei16736 2009-11-02 20:45
浏览 9
已采纳

如果出现用于制作功能按钮的语句?

I am on my 2nd day(16th hour) of trying to get my delete button to do what I want with PHP. I have a site that is a social network that has user profiles. Users can leave comments on another users profile. I am trying to put a delete link in a designated area that only shows up if you are viewing your own profile and goes away when you are viewing someone elses profile. I am also not wanting to make a delete confirm page. I want the page to reload with the comment selected to delete gone, and be sent to my db marked as dead. This is what I have so far:

           <?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.blah.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.blah.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 ($poster->id == $prof->id)
           echo "<a href='http://www.blah.org/DeleteComment.php?id=".$prof->id."'>";
           echo " delete";
           echo "</a>";
           echo "</div>";
           echo "</div>";
           echo "</div>";
           }

           ?>

do I need to make a seperate query underneath the one I already have that is for the composition of the comments? do I need to add on to that query? how do I make the delete button only appear when the user is looking at their own page? how do I make the page reload with the comment gone after I selected it deleted and mark it dead in the db?

thank you in advance

  • 写回答

3条回答 默认 最新

  • dongxuandong2045 2009-11-02 20:56
    关注

    This is toatlly lame, code, but just a random thought since you are really giving us nothing to work with. Take it for what it is:

    function getPageUserID()
    {
        return $_GET['userID'];
    }
    if ($user->userID == getPageUserID())
    {
     //show delete button
        echo '<button value="Delete">Delete</button>';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大