if(isset($_POST['postid'])){ $deletepost = "DELETE FROM chat WHERE id='".$postid."' "; mysql_query($deletepost); } ?>is supposed to delete the post with the corresponding post id. But instead, it deletes the oldest entry in the database.
Here is the full code for the page if it could help.
<?php include('includes/connect.php'); $queryget = mysql_query("SELECT * FROM chat ORDER BY id DESC"); while($row = mysql_fetch_assoc($queryget)) { $postid = $row['id']; $name = $row['name']; $message = $row['message']; $time = $row['time']; echo" <div id='name'> <b>$name</b> Skrev:</div> <div id='message'> ".strip_tags($message).$postid." <br /></div> <div id='time'> <b> Klockan: $time</b> "; if (is_admin(mysql_real_escape_string($_SESSION['username'])) == true){ echo " <form action='index.php?page=chat' method='POST'> <input type='hidden' value='".$postid."' name='postid' /> <input type='submit' value='delete' /> </form> "; } echo" </div><hr> "; } if(isset($_POST['postid'])){ $deletepost = "DELETE FROM chat WHERE id='".$postid."' "; mysql_query($deletepost); } ?>Wasn't too sure if this was a PHP or SQL related question, so Jacek can feel free to move this if needed / wanted .