I have a table of player data with a delete button next to each row. When the button is clicked, it should delete that specific row instantly using jQuery. I have included my code thus far. I am really stuck when the button should be clicked. Should I use a header function?
index.php
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css"></link>
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<!-- Create a table-->
<table style width="800" border="1" cellpadding="1" cellspacing="1">
<!-- Create headings. Every row is defined as with <tr> tag-->
<!-- Create headings. Every row is defined as with <tr> tag-->
<tr>
<th>Player ID</th>
<th>Player Name</th>
<th>Player Position</th>
<th>Delete</th>
</tr>
<?php
require "php/conn.php";
//Select query
$res = $db -> query ("SELECT * FROM player");
//Set pointer to 1
$res -> data_seek(0);
//Display data using while loop
while ($row = $res -> fetch_assoc()) {
// Write html code in php using this method
echo "<div class = 'row'>";
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['surname']."</td>";
echo "<td>".$row['position']."</td>";
echo "<td><button id = 'dlt_btn' type='button'>Delete</button></td>";
echo "</tr>";
echo "</div>";
}
?>
</body>
script.js
$(document).ready(function () {
$("#dlt_btn").click(function(){
//Activate 'delete.php'
});
});
delete.php
?
id='dlt_btn_".$row['id']."'