Hope you´re doing well today. ;)
First of all, here is my problem:
Im loading data from my database table dynamic in a HTML-table. So far, so good. The dynamic loading of the data in my HTML table works pretty well...
Now, I want to check if the delete button is pressed and also want the ID from the record where the delete button was pressed.
The HTML table has the following values: id, FirstName, LastName, Radio-Button (To select the record which should be deleted later on), Delete - Button (To delete the selected record)
Here is my source Code:
<?php
$query = $con->prepare("SELECT id, vorname, nachname, herkunftsland FROM schauspieler;");
$query->bind_result($id, $firstname, $lastname, $city);
$query->execute();
while($query->fetch()) {
$actor_information[$id]['id'] = $id;
$actor_information[$id]['firstname'] = $firstname;
$actor_information[$id]['lastname'] = $lastname;
$actor_information[$id]['city'] = $city;
}
?>
<html>
<head>
<title></title>
</head>
<body>
<p></p>
<h4>Actors:</h4>
<hr /><br />
<!--
<table border="3">
<tr>
<td><input type="radio" name="1"></input></td>
<td><input type="radio" name="1"></input></td>
<td><input type="radio" name="1"></input></td>
<td><input type="radio" name="1"></input></td>
</tr>
</table>
-->
<form action="" method="post">
<table border="3">
<th>id</th>
<th>FirstName</th>
<th>LastName</th>
<th>City</th>
<?php
foreach($actor_information as $key => $value) {
echo "<tr>";
printf("<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><input type='radio' name='dvd_id' value='%s'></input></td><td><input type='button' name='delete_actor' value='delete'></input></td>", $value['id'], $value['firstname'], $value['lastname'], $value['city'], $value['id']);
echo "<tr>";
}
?>
</table>
</form>
Could anyone help me out to get the ID from the selected record...? I just need it to delete the record where the radio button is set.
Hopefully I can get some help from you guys...
Best regards & have a nice day, Peter