I have this code which gets the contents from a mysql databse.
So basically, what happens is that foreach row in the database, it creates a div with the contents in. However, I want the user to be able to delete the post, but I simply can’t get my head around how to do it.
This is the code:
while($row = mysql_fetch_assoc($query))
{
$contents= $row['contents'];
}
echo '<div class = "post" style = "margin-right: 300px;">'.$contents.'<br><p>DELETE -- HOW CAN I DO THIS??</p></div>';
Basically, what this does is get the contents of the row, each time. But I want the user to be able to click on delete it, and it deletes the div which has the contents, and removes it from the database.
I have tried simply to delete the div, but that deletes ALL the divs, not just the one that I clicked delete in.
How can I do this, I don’t care how.
Thanks. I am sorry if there is too much info, or I ask too much.
I have found out what to do.
Here is what I did:
And on the
delete.phpI have something like this: