Re: deleting records using a checkbox
| From: | Foong | Date: | Wed, 19 Mar 2003 05:29:37 +0000 |
| Subject: | Re: deleting records using a checkbox | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26460@lists.php.net to get a copy of this message | ||
helo,
make your checkbos name into array:
<INPUT TYPE="CHECKBOX" NAME="DELETE[<?php echo message_id ?>]"
VALUE="Y">
you will get an array named DELETE.
check for every element in array DELETE
foreach($_POST['DELETE'] as $message_id => $val) {
if($val ==1) {
// delete record where messahe ID equals to $ message_id
}
}
hope this help
Foong
"Mark" <thejack@btinternet.com> wrote in message
news:20030317070237.66749.qmail@pb1.pair.com...
> hello
> 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??
>
> please help me!!!!
>
>