Page 1 of 1

Ticking Checkboxes with Edit/Delete Options

Posted: Tue Nov 23, 2010 5:18 pm
by CoolAsCarlito
Both sets of code are from the same file. If a user ticks one of the check boxes for one of the records in the table then selects edit then clicks the Apply button I want it to load the edit form into the content div with it passing the id variable of the selected record so that when it gets to the edit for it will be able to use that id to gather the information on that record from the database. If the user ticks a record in the table then selects delete the clicks the Apply button then I want it to delete the record from the database.

Code: Select all

<div class="listActions">
                  <form action="" method="post">
                     <label for="actionSelect">With selected items: </label>
                     <select class="select" name="actionSelect" id="actionSelect">
                        <option>Edit</option>
                        <option>Delete</option>
                     </select>
                     <button class="button small-button"><strong>Apply</strong></button>
                  </form>
               </div>

Code: Select all

<?php 
                    while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) {
                          echo '
                          <tr>
                          <td><input type=checkbox class=checkbox /></td>
                    <td>' . $row['menuname'] . '</a></td>
                          <td><a href=# id="menuitems" title="' . $row['menuname'] . ' Structure Items">Menu Items</a></td>
                    <td>' . $row['name'] . '</a></td>
                    <td class=last>' . $row['datecreated'] . '</td>
                    </tr>';
                        }
                    ?> 

Re: Ticking Checkboxes with Edit/Delete Options

Posted: Tue Nov 23, 2010 8:23 pm
by s.dot
Put the row id in the value attribute of the checkbox form element.

Code: Select all

<input type="checkbox" class="checkbox" value="<?php echo $row['id']; ?>">
If you want to allow for multiple editing/deleting.. then something like this will work

Code: Select all

<input type="checkbox" class="checkbox" value="checkboxes[<?php echo $row['id']; ?>]">