Jump to content

Deleting database rows from an array of variables


denhamd2

Recommended Posts

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 :)

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.