Alanay Alanay - 1 year ago 63
MySQL Question

How Do I Give Each Row In MySQL Delete Button With PHP?

I need each row to have a unique button beside it which will delete the message. I need it to only be able to be deleted by the receiver. My first thought was to echo a HTML form inside the while loop. I don't think that would work though. If it does work what would the SQL statement inside

look like? Each message has an ID so could I use that? If you need to see rest of the code let me know.

$Select = "
SELECT * FROM Messages
WHERE Receiver='$Identifier'
LIMIT 10";
$Result = $Connect->query($Select);

if (mysqli_num_rows($Result) > 0) {
while ($Row = mysqli_fetch_assoc($Result)) {
echo nl2br("Sender = " . $Row["Sender"] . " Message = " . $Row["Message"] . "\n");

Answer Source

why don't try this:

echo "Sender = " . $Row["Sender"] . " Message = " . $Row["Message"] . "<button id=".$Row["ID"].">Delete</button>";

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download