Forums

Delete A Record

mhmdmed 23 Mar, 2012
Hello Sir,

Can you please tell me an easy method of how to delete a record.

I already read our tutorials about add a record and edit it and it works
superb.

I just need to know how to delete


Thank you
GreyHead 23 Mar, 2012
Hi mhmdmed,

Is this from a listing? Normally I just add a little PHP to a form to check if there is a delete parameter in the URL and then add the MYSQL to delete the identified record. It should be something like:
<?php
if ( $form->data['task'] == 'delete') {
  $db =& JFactory::getDBO();
  $query = "
    DELETE
      FROM `#__table_name`
      WHERE `param` = 'value' ;
  ";
  $db->setQuery($query);
  $data = $db->query();
}
?>


Bob
awoolbert 13 Sep, 2012
Bob- how would you set the delete parm on the URL in this case. For example, I have a regular edit URL : index.php/home/data-selector-test.html?chronoform=professional-team-data-edit&token=93

so how would I build the PHP code onto the record edit form to delete. I get the delete from table portion, but not the linking it into the form
GreyHead 14 Sep, 2012
Hi awoolbert,

&task=delete

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