在用户配置文件中,我试图只允许用户查看他们发布到数据库的内容,但是通过这种编码方式,它可以在每个用户帐户中显示数据库中的所有内容。我怎样才能让它只回显用户创建的内容。
<?php
include("headers.php");
if($_POST['delete']) {
$title=$_POST['title'];
echo $title;
$result = mysql_query("DELETE FROM test2 where fname='$title'");
if($result)
echo "<div style='color:red;'>The ".$row['fname']." datas are deleted successfully.<br> <br></div>";
}
if($_POST['submit']) {
$title=$_POST['title'];
$result = mysql_query("SELECT * FROM test2 where fname='$title'");
$row = mysql_fetch_assoc($result);
@$image=$row ['photo'];
echo "<div style='width: 600px;border: 1px solid black;padding: 30px;float: center;text-align: center;margin: auto;margin-top: 140px;'> <span style=' font-size: 20px; font-weight: bold;'>Recent Post</span><br><br>
<table style='width:100%;border-bottom:1px solid gray;'><tr><td><table style='width:90%;'><tr><td>Name:</td><td>".$row['fname']."</td></tr>
<tr><td>Start Date:</td><td>".$row['stdate']."</td></tr>
<tr><td>End Date:</td><td>".$row['endate']."</td></tr>
<tr><td>Address:</td><td>".$row['addr1']."</td></tr>
<tr><td></td><td>".$row['addr2']."</td></tr>
<tr><td></td><td>".$row['city']."</td></tr>
<tr><td></td><td>".$row['state']."-".$row['zip']."</td></tr>
<tr><td>Description:</td><td>".$row['description']."</td></tr>
<tr><td>Link:</td><td><a href=".$row['link'].">".$row['link']."</a></td></tr>
</table></td><td><img src='image/".$image."' alt='image' style='width:100px;height:100px;'></td></tr></table><br/><br/><a href='index.php'>Go Back To Home </a></div>";
// echo "<div style='width:90%;float:center;border-bottom:1px solid blue;'></div>";
} else {
$result = mysql_query("SELECT * FROM test2");
echo "<div style='width: 600px;border: 1px solid black;padding: 30px;float: center;text-align: center;margin: auto;margin-top: 140px;'> <span style=' font-size: 20px; font-weight: bold;'>Recent Post</span><br><br>";
while($row = mysql_fetch_array($result))
{
@$image=$row ['photo'];
echo "<table style='width:100%;border-bottom:1px solid gray;'><tr><td><table style='width:90%;'><tr><td>Name:</td><td>".$row['fname']."</td></tr>
<tr><td>Start Date:</td><td>".$row['stdate']."</td></tr>
<tr><td>End Date:</td><td>".$row['endate']."</td></tr>
<tr><td>Address:</td><td>".$row['addr1']."</td></tr>
<tr><td></td><td>".$row['addr2']."</td></tr>
<tr><td></td><td>".$row['city']."</td></tr>
<tr><td></td><td>".$row['state']."-".$row['zip']."</td></tr>
<tr><td>Description:</td><td>".$row['description']."</td></tr>
<tr><td>Link:</td><td><a href=".$row['link'].">".$row['link']."</a></td></tr>
</table></td><td><img src='image/".$image."' alt='image' style='width:100px;height:100px;'></td></tr></table>";
}
echo "<br/><a href='index.php'>Go Back To Home </a></div>";
}
?>