Within the user profile I am trying to only allow the user to see what they have posted to the database but with the coding this way it shows everything from the database in every users account. How can I get it to only echo what the user has created.
<?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>";
}
?>