I am trying add a "Delete" button in my application. The button's functionality is to remove the database row when it is clicked. I guess I will need to create something like delete.php
and link the button to it. But I have no idea how to do it. Can anyone help?
Below is my code:
<table id="edit_accounts" class="tablesorter">
<thead>
<tr><?php
while($v=mysql_fetch_field($result)) if($v->name!="paid_for_year_date" && $v->name!="approved"){
?><th class="header"><?php echo display_version($v->name);?></th>
<?php
}
?>
<th class="header">Actions</td>
</tr>
</thead>
<?php
while($row=mysql_fetch_assoc($result)){
$row["category"]=$categories[$row["category"]]["category_name"];
$pfydate=$row["paid_for_year_date"];
unset($row["paid_for_year_date"]);
$extra_link="";
if($pfydate==$row["join_date"]){
$extra_link="<br/><a href='mark_as_paid.php?account_id=".$row["account_id"]."&auth_code=".md5("lgotadmin".$row["account_id"])."'>Mark as Paid</a>";
}
if($row["approved"]==0){
$extra_link.="<br/><a href='approve.php?account_id=".$row["account_id"]."&auth_code=".md5("lgotadmin".$row["account_id"])."'>Approve</a>";
}
unset($row["approved"]);
?>
<tr><td><?php echo implode("</td><td>",$row);?></td><td><a href="edit_account.php?account=<?php echo $row["account_id"];?>">Edit Account</a><br><a href="view_transactions.php?account=<?php echo $row["account_id"];?>">Edit Transactions</a><br/><a href="delete.php?account_id=".$row[account_id"]<?php echo $row["account_id"];?>">Edit Account</a><?php echo $extra_link;?></td></tr>
<?php
}
?>
</table>
mysql_
library is deprecated. You should look at moving tomysqli_
orPDO
.