Re: deleting records using a checkbox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
20030317070237.66749.qmail@pb1.pair.com">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!!!!
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux