Hi, I am trying to add a delete link to my page and have followed the above but cant seem to get it to work, when clicking delete all I get is a blank page, and when I go back to the list the item hasnt been deleted.
I created a form to do the deleting called deletelead , I added the load html action, and in the code of the form added .
<?php
$task = JRequest::getString('task', '', 'get');
if ( $task = 'del' ) {
$cf_id = = JRequest::getInt('cf_id', '', 'get');
if ( $cf_id 0 {
$db =& JFactory::getDBO();
$query = "
DELETE
FROM `hqfjt_chronoforms_data_addupdatelead`
WHERE `cf_id` = '{$cf_id}' ;
";
$db->setQuery($query);
$db->query();
}
}
$mainframe =& JFactory::getApplication();
$mainframe->redirect('index.php');
?>
On my view page I have the following code, but clicking on the delete just give the above problem, I also have a problem with the edit button too, when clicked it goes to the form I made to submit data but doesn't import the fields from the database and just presents a blank form.
<table class="sortable">
<tr class="table-header">
<td>Name</td>
<td>Company</td>
<td>Postcode</td>
<td>Gas Oil</td>
<td>Derv</td>
<td>Kero</td>
<td>Edit</td>
<td>Delete</td>
</tr>
<?php
foreach($form->data['leaddetails'] as $detail):
?>
<tr>
<td><?php echo $detail['leadname']; ?></td>
<td><?php echo $detail['businessname']; ?></td>
<td><?php echo $detail['postcode']; ?></td>
<td><?php echo $detail['gasoiluser']; ?></td>
<td><?php echo $detail['dervuser']; ?></td>
<td><?php echo $detail['kerouser']; ?></td>
<td><a href="index.php?option=com_chronoforms&chronoform=addupdatelead&token=<?php echo $detail['cf_uid']; ?>">Edit</a></td>
<td><a href='index.php?&option-com_chronoforms&chrononame=deletelead&<?php echo $detail['cf_uid']; ?>' >Delete</a></td>
</tr>
<?php
endforeach;
?>
</table>
Sorry if im a bit rubbish, its my first time doing anything more advanced than contact forms etc with chrono so its hard work.