简体   繁体   中英

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 if(isset()) 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'
ORDER BY ID
DESC
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");
    }
}

为什么不试试这个:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM