
How can I delete a row from a database with a button, displayed using php?
I would like to be able to delete a row using the delete-button I display at the end of each row.I need two queries to delete a person from my database completely since I have a n-m relationship
between Persons and Functions.
The queries are as follows:
delete from Persons_Functions where `Person ID` = '1'; delete from `Persons` where `Person ID` = '1';I would like to implement these queries using the delete-button provided in the actual code,
how can I do this?
<table> <thead> <tr> <?php $query = "SELECT p.`Person ID`, p.`First Name`, p.`Last Name`, p.Gender, p.`Date Of Birth`, p.Email, p.`Phone Number`, c.Region, c.Country, p.`Delegation ID` FROM Persons as p, Chapters as c WHERE c.`Chapter ID`=p.`Chapter ID` ORDER BY p.`Delegation ID"; $result = mysql_query($query) or die($dberror3 . mysql_error()); $row = mysql_fetch_assoc($result); foreach ($row as $col => $value) { echo "<th>"; echo $col; echo "</th>"; } ?> </tr> </thead> <tbody> <?php mysql_data_seek($result, 0); while ($row = mysql_fetch_assoc($result)) { ?> <tr> <?php foreach($row as $key => $value){ echo "<td>"; echo $value; echo "</td>"; } ?> <td><button type="button">Delete</button></td> </tr> <?php } ?> </tbody> </table>
where is javascript
–
Satender K
12 mins ago
|
|||||
1 Answer
I would use JavaScript and Ajax here.
|
|||