Forums

How to delete a record

lopezio 12 Apr, 2011
Hi
Why this code doesn't work as expected (delete the record with Id=13)

<?php
$db =& JFactory::getDBO();
$query = "DELETE FROM dt_brotero WHERE Id =13"; 
$db->setQuery($query);
$db->query();
?>

I write this code OnSubmit after send emails.
I have one Chrono conectivity with a list of records and I'll create a form that deletes one of them. After deleting the record I want to be redirected to where I came from.
Thank you for your help
GreyHead 13 Apr, 2011
Hi lopezio,

Test the query in PHPMyAdmin to see if you get an error. Possibly `Id` should be `id` ???

Bob
lopezio 13 Apr, 2011
Hi Greyhead
I found the problem. If I have one submit button in my form the code works fine.
If I write the code in MainOnloa it works fine.
Thank you
This topic is locked and no more replies can be posted.