hello
trying to add a mass-delete function a WP-plugin, which works fine if you want to delete 1,2,3 or 4 entries, but anything higher is lost.
Perversely, it doesn't even take the missing elements from with end of the array, it takes the from the middle!!
Grr, help!!
This is the function that writes the table:
PHP Code:
function mp_timetable_results(){
global $wpdb;
$table_name = $wpdb->prefix . "mf_timetable";
$query="SELECT * FROM " . $table_name;
$results = $wpdb->get_results($query);
?><form name="timetable_delete" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"><input type="hidden" name="mf_timetable_delete_hidden" value="Y"><table class="mf_timetable_admin"><?php
foreach ($results as $results){
?><tr><?php
?><td><?php
echo covert_day_output($results->day);
?></td><?php
?><td><?php
echo $results->class;
?></td><?php
?><td><?php
echo $results->location;
?></td><?php
?><td><?php
echo $results->start;
?></td><?php
?><td><?php
echo $results->end;
?></td><?php
?><td><?php
echo $results->teacher;
?></td><?php
?><td>£<?php
echo $results->cost;
?></td><?php
?><td><?php
echo $results->category;
?></td><td><input type="checkbox" name="<?php echo $results->class; ?>" value="<?php echo $results->id; ?>" /></td></tr><?php
}
?></table><input type="submit" name="delete_selected" value="<?php _e('delete selected', 'mf_timetable_delete' ) ?>" /></form>
<?php
}
and this is the delete function
PHP Code:
function mp_timetable_delete(){
global $wpdb;
//var_dump($_POST);
echo implode(",", $_POST);
$table_name = $wpdb->prefix . "mf_timetable";
foreach ($_POST as $list){
$sql= "DELETE FROM " . $table_name .
" WHERE id = " . $list;
$test=$wpdb->query($sql);
};
?>
<div class="updated"><p><strong><?php _e('Event Deleted.'); ?></strong></p></div>
<?php
}