Suppression de plusieurs éléments dans un tableau
onjour
J'ai un tableau et je souhaite supprimer une ou plusieurs données en cochant une ou plusieurs boxe.
mon problème est que les données ne s'effacent pas. Auriez vous une solution à me proposer, peut être ai je fait une erreur. La page s'actualise.
Merci beaucoup
j'ai fait ceci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| case 'delete_all':
if ($_POST['selected'] != '') {
foreach ($_POST['selected'] as $suppliers['suppliers_id'] ) {
tep_db_query("delete from " . TABLE_SUPPLIERS . " where suppliers_id = '" . (int)$suppliers['suppliers_id'] ."' ");
tep_db_query("delete from " . TABLE_SUPPLIERS_INFO . " where suppliers_id = '" . (int)$suppliers['suppliers_id'] . "'");
$products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where suppliers_id = '" . (int)$suppliers_id . "'");
tep_db_query("update " . TABLE_PRODUCTS . " set suppliers_id = '',
products_status = 0
where suppliers_id = '" . (int)$suppliers['suppliers_id'] . "'
");
}
}
tep_redirect(tep_href_link(FILENAME_SUPPLIERS),'page='.$_GET['page']);
break; |
en outre dans mon html j'ai ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
<script type="text/javascript">
//-----------------------------------------
// Confirm Actions (delete, uninstall)
//-----------------------------------------
$(document).ready(function(){
// Confirm Delete
$('#form').submit(function(){
if ($(this).attr('action').indexOf('delete',1) != -1) {
if (!confirm('Delete/Uninstall cannot be undone! Are you sure you want to do this?')) {
return false;
}
}
});
});
</script> |
mon code html
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<div class="buttons"><a class="button" onclick="$('form').submit();"><span><?php echo tep_image_button('button_delete_big.gif', IMAGE_DELETE); ?></span></a></div>
<div style="width:100%;">
<form <?php echo 'action="' . tep_href_link(FILENAME_SUPPLIERS, 'page=' . $_GET['page'] . '&action=delete_all', 'NONSSL') . '"'; ?> method="post" enctype="multipart/form-data" id="form">
<div style="width:100%;">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
<tr class="dataTableHeadingRow">
<td width="40" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
.....
</tr>
<tr>
<td>
<?php
if ($suppliers['selected']) {
?>
<input type="checkbox" name="selected[]" value="<?php echo $suppliers['suppliers_id']; ?>" checked="checked" />
<?php
} else {
?>
<input type="checkbox" name="selected[]" value="<?php echo $suppliers['suppliers_id']; ?>" />
<?php
}
?>
</td>
.....
</tr>
</table>
</div>
</form>
</div> |