Jump to content

Dynamic Checkbox Deletion Not Working


johne90

Recommended Posts

I have been stuck on why this won't work for a while now. It doesn't give any errors, it seems like everything is fine, it just doesn't delete anything.

 

if ( isset($_POST['remove_selected']) ) {
  $postCount = count($_POST['id']);
  for ( $i=0; $i < $postCount; $i++ ) {
    $deleteIds .= $_POST['id'][$i].',';
  }
  $deleteIds = rtrim($deleteIds,',');
  mysql_query('delete from items where id in ('.$deleteIds.')');
}

 

                <form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td>
                    <ul id="container" class="codeBoxes">
                     <?
                     echo "<li><input class=\"checkbox\" type=\"checkbox\" value=\"$id\" name=\"id[]\"></li>";
                     ?>
                    </ul>
                    </td>
                  </tr>
                  <tr>
                    <td>
                    <input type="Submit" name="remove_selected" value="Remove Selected">
                    </td>
                  </tr>
                </table>
                </form>

 

If anyone knows whats wrong I would really appreciate the help.

Link to comment
https://forums.phpfreaks.com/topic/92463-dynamic-checkbox-deletion-not-working/
Share on other sites

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.