编辑选项仅对在 php 中上传的用户可见
Edit option visible only to the user who uploaded in php
基本上我想添加一个编辑选项,该编辑选项应该只对上传的人可见(就像在 Facebook 中编辑选项只对上传故事的人可见)内容,这里是内容由 php 文件 (upload.php) 上传并以砖石布局显示,可能的解决方案是什么?虽然我可以在 [=14] 上为用户提供编辑 link =] 文件并借助分配给每个网格项目的 id,我可以 edit.But 在网格本身上提供编辑 link(仅对上传它的人可见)将是一个更好的主意。
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>";
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)
}
基本上我想添加一个编辑选项,该编辑选项应该只对上传的人可见(就像在 Facebook 中编辑选项只对上传故事的人可见)内容,这里是内容由 php 文件 (upload.php) 上传并以砖石布局显示,可能的解决方案是什么?虽然我可以在 [=14] 上为用户提供编辑 link =] 文件并借助分配给每个网格项目的 id,我可以 edit.But 在网格本身上提供编辑 link(仅对上传它的人可见)将是一个更好的主意。
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>";
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)
}