Checkbox & Hidden Field to Delete Row

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

 



Ave,

I¹m stuck on a problem here.
I have a file manager kind of application and I¹m trying to add the
functionality to delete multiple files.

Basically, there¹s a bunch of rows generated dynamically. Each row has a
checkbox for ³Delete² option, and a hidden field which contains the name of
the File associated with the record. If a user checks a checkbox to delete
certain rows, it should be able to delete those rows from mySQL as well as
delete the files associated with that record.

I created both the checkboxes & the hidden fields to be Arrays. I run a loop
to delete all rows (based on ID¹s) where the checkbox was Checked. It does
that part fine... The problem is linking the Filename array to the Checkbox
Array. It deletes the first two files uploaded no matter what rows are
checked. Basically, the Filename array is not associating with the Checkbox
array. So if  a person checks the 3rd and 5th checkbox... The 3rd & 5th row
is deleted from mySQL, but the 1st and 2nd file is deleted, not the 3rd &
5th. 

Following is my code to generate the checkboxes & hidden fields...

                            <td width=15><span class=\"style11\"> <input
type=checkbox name=thisID[] value=$myrow[ID]><input type=hidden
name=\"PF[]\" value=\"imsafm/$showfilesuser/$myrow[filename]\"><input
type=hidden name=login value=$login><INPUT TYPE=hidden name=showfilesuser
value=$showfilesuser></td>

Following is the code to delete the checked rows/files...

    for($I=0;$I<sizeof($thisID);$I++) {
    $sql = "DELETE FROM file WHERE ID='$thisID[$i]'";
        $result = mysql_query($sql) or die("Fatal Error: ".mysql_error());
        $thefile = "$PF[$i]";
        unlink($thefile);
    }

I have no clue what to do... It¹s just not working out.

Rahul S. Johari
Coordinator, Internet & Administration
Informed Marketing Services Inc.
500 Federal Street, Suite 201
Troy NY 12180

Tel: (518) 687-6700 x154
Fax: (518) 687-6799
Email: rahul@xxxxxxxxxxxxxxxxxxxx
http://www.informed-sources.com


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux