How to create a working delete button?
Posted: Mon Jul 19, 2010 5:48 am
Hello, newby question here. I have a code showing comments, but I can't figure out a way to make a delete button for them, here's my code:
so the thing is - all my comments are being deleted on page refresh and I can't have more than one comment at a time, but with this source I can delete that one. So can you give me some hints or maybe the exact code even, if it's not too much to ask? Thanks.
Code: Select all
$result = mysql_query("SELECT * FROM comment ORDER BY P_Id DESC;");
while($row = mysql_fetch_array($result)) {
$delete = mysql_query("delete from comment where P_Id = $row[P_Id]");
echo "<a href='?delete&id=$row[P_Id]'>[x]</a> <span class='name'>" . $row['name'] . "</span>: " . $row['comment'] . "(" . $row['P_Id'] . ")" . "<br/><br/>"; }