> i have been trying to delete items from a guestbook using multiple > checkbox > fields but have had no success > > this is the code i have been using to add the checkbox's to the records: > > while ($rows = mysql_fetch_array($result)) { > > <?///////////////////////////////////////////////////////////////?> > <? //TABLE TO SHOW THE CONTENTS OF USER_MESSAGE DATABASE TABLE ?> > <?///////////////////////////////////////////////////////////////?> > > <HTML> > <HEAD> > <TITLE>Queen Vic Message Book</TITLE> > </HEAD> > <BODY> > > <P><TABLE BORDER="1" WIDTH="600" BORDERCOLOR=#F00000> > > <TR> > <b>Date/Time Posted:</b> <? echo $orgdate; ?> > </TR> > > <TR> > <TD><b>Name:</b> <? echo $rows['name']; ?></TD> > > <TD><b>Email:</b> <A HREF="mailto:<? echo $rows['email']; ?>"> > <? echo $rows['email']; ?></TR></TD> > > > > <TR><TD COLSPAN="4"> > <? echo $rows['message']; ?> > </TD></TR> > </TABLE> > <TD> > <b>Delete Message</b> <INPUT TYPE="CHECKBOX" NAME="DELETE" VALUE="Y"> > </TD> > </P> > </BODY> > </HTML> > > <?/////////////////////////////////////////////////////////////////?> > <?//// CLOSES LOOP CREATED FOR ADDING DATA TO TABLE?> > <?/////////////////////////////////////////////////////////////////?> > <? } ?> > > this does add a checkbox to every record in the guestbook > > how do i link the checkbox to each message id (which are auto incremented) > and then pass some code to delete every checked item?? Well, you should start by passing an ID as the value of the checkbox, so you know which message was checked. What good is passing 'Y' going to do you? You also need to make the checkbox an array, since, if I've read correctly, you'll have multiple checkboxes and want to delete multiple messages at the same time, right? <input type="checkbox" name="delete[]" value="<?=$rows['ID']?>"> Now, when that form is submitted, only the checkboxes you've selected will be present in $_POST['delete'] or $_GET['delete'], depending on the action of your form. Speaking of... WHERE IS YOUR FORM TAG? You know, <form> and </form>?? To process the delete, you can do this: $delete_ids = implode(",",$_POST['delete']); $query = "DELETE FROM table WHERE ID IN ($delete_ids)"; Hope that helps... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php