编辑选项仅对在php中上传的用户可见

时间:2015-08-29 09:26:43

标签: javascript php jquery jquery-masonry

基本上我想添加一个编辑选项,该编辑选项应仅对上传的人可见(就像在Facebook中,编辑选项仅对上传故事的人可见)内容,此处内容已上传通过php文件(upload.php)并以砖石布局显示,可能的解决方案是什么?虽然我可以在upload.php文件上为用户提供编辑链接,并在id分配给每个网格的帮助下 - 我可以编辑的项目。但是在网格本身上提供编辑链接(仅对上传它的人可见)将是一个更好的主意。

  echo "<div class='mainlayout' data-js-module='layout'>";
                echo "<div class='grid' style='position: relative;'>";
                  include "mysql.php";
                  $query= "SELECT ID,Title,Summary,Content,ImgName,Image FROM content ORDER BY ID DESC";
                  $result=mysql_query($query,$db);
 while($row=mysql_fetch_array($result))
                    {  
echo "<div class='grid-item item1' style='position: relative; left: 240px; top: 0px; background: ".ran_col().";'>";           
 echo"<div class='show-image'>";
                        echo '<img class="image" src="data:image;base64,'.$row['Image'].' " height="240" width="210" style="border: 5px; border-radius: 5px; float:left; position:relative;"/>'; echo"</div class='show-image'>"; 
echo "<div class='content-short' style='position:relative;'>";

                            $string = $row['Content'];
                            if (strlen($string) > 200) 
                            {
                              $trimstring = substr($string, 0,200). '...';
                            } 
                            else 
                            {
                              $trimstring = substr($string,0). '...';
                            }
                            echo $trimstring;
                            $id= $row['ID'];
                        echo "</div>";

                        echo "<div class='content-full'>";
                          echo $row['Content'];
  echo "</div>";
echo '<script type="text/javascript">$(".content-full").hide();</script>';
        echo "</div>";
                    }
                  mysql_close($db); 
                echo "</div>";
              echo "</div>";  

1 个答案:

答案 0 :(得分:0)

See, Use session_start() for starting the session. 
So, when any user is log in, his/her Session ID will be created. OK.

And, When any user is submitting his comment, his/her ID is also submitted in database table.

So, now you are having $_SESS['Sess_ID'] & MemberID(which is inserted in database table).

Keep one if condition there.

if($_SESS['Sess_ID']==$MemberID) //Mind it, This $MemberID coming from database table where all comments are submitted. 
{
    //EDIT option (for the person who logged in when his/her $MemberID matches)
}
else
{
    // Normal Option (for Rest of the users)
}