denhamd2 Posted May 23, 2007 Share Posted May 23, 2007 Hi, I have a form with a list of checkboxes, which are each filled with a date in the format 27012007, for example. The name of each of the checkboxes is the same as the date. Basically when the user presses the submit button I would like all rows in the database table "users" with the corresponding column "date" to be deleted when the form variables date correspond to those in the "date" rows. I think all the checked dates might also need to be put into an array. Would anyone know how to do this? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/52629-deleting-database-rows-from-an-array-of-variables/ Share on other sites More sharing options...
denhamd2 Posted May 23, 2007 Author Share Posted May 23, 2007 ok here's what i have so far: i have my checkboxes in a repeat loop: <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row_get_forum_messages['date']; ?>" /> then a submit button: <input name="delete" type="submit" id="delete" value="Delete"> then here's my php code: <?php if($_POST['delete'] == "Delete"){ for($j=0;$j<$num_rows;$j++){ $del_id = $checkbox[$j]; $sql = "DELETE FROM bookings WHERE date='$del_id'"; $result = mysql_query($sql); echo $result; } } ?> ... but it doesn't work, it doesnt delete any rows just reloads the page, any ideas? Link to comment https://forums.phpfreaks.com/topic/52629-deleting-database-rows-from-an-array-of-variables/#findComment-259717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.