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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.