I have a page showing all transactions made via paypal on my site. I want to add a button that could delete that specific row.
The transaction id is unique.
how would I be able to when user clicks on the button to delete just that row? also to run a jquery alert to confirm delete?
my code:
<table class"widefat">
<?php global $wpdb;
$result = $wpdb->get_results ( "SELECT * FROM wp_donations" );
if (!$result){?>
<tr>
<td>There are no donations to show</td>
</tr>
<?php }else{?>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone Number</th>
<th>Address</th>
<th>Amount</th>
<th>Method</th>
<th>Date</th>
<th>Transaction ID</th>
<th></th>
</tr>
</thead>
<?php foreach ( $result as $print ) {?>
<tr>
<td><?php echo $print->name;?></td>
<td><?php echo $print->email;?></td>
<td><?php $phones = $print->phone; if($phones == 0){echo 'No Number Provided';}else{echo $phones;}?></td>
<td><?php echo $print->address;?></td>
<td>$<?php echo $print->amount;?></td>
<td><?php echo $print->method;?></td>
<td><?php echo $print->dates;?></td>
<td><?php echo $print->txid;?></td>
<td><input type="button" id="<?php echo $print->txid;?>" class="delete" title="Delete" value="delete" /></td>
</tr>
<?php }?>
</table>
If jquery is an option , then it is very simple :
check this
I ended up running an action. using the unique ID that is
AUTO_INCREMENT
in the database.and then called the action on page load.