how can i add a delete button ??thanks."> ho to delete a database row - Forums

Forums

ho to delete a database row

coppo82 19 Jun, 2013
hi in a new form i display information of a database

banner name and the relative banner image.

i would like to add a DELETE button for each displayed row.

this is the code that i add for display the information.

<?php
$data =& $form->data['Xj5egChronoformsDataWerbung'];
foreach ( $data as $k => $v )
 {
echo "Banner Name :{$v['banner_name']}<p>";
echo "<div><img src='/components/com_chronoforms/uploads/werbung/{$v['banner_img']}' /></div><p>";
echo "<p>";

}
?>


how can i add a delete button ??

thanks.
GreyHead 19 Jun, 2013
Hi coppo82,

First, I avoid *really* deleting rows - instead a use a status column and mark them 'deleted'. Then check for this in any listing; that way I can get them back if there is a mistake.

There are two ways to to delete a record:

One is to use a link to a separate little form that just says 'Do you really want to delete record xxx???' and has a Delete button. When it is submitted the form deletes the record with PHP in a Custom Code action then returns the user to the original form.

The second way is to use Ajax and have a separate form event to do the deletion (the same code is used for the deletion). This way the user never has to leave the original form.

Bob
This topic is locked and no more replies can be posted.