I am trying to delete MySQL table rows from a Web page using Perl. I want to iterate over checkboxes and if one is checked, that row from the database will be deleted. I have made the value of the checkbox the auto incrementing key value. Here is a piece of my code, so you can get an idea of where I am at, table-wise:
while (@data = $STH1->fetchrow_array()) {
print "<tr>";
print " <td>$data[2]</td>";
print " <td>$data[3]</td>";
print " <td>$data[7]</td>";
print " <td>$data[6]</td>";
print " <td>$data[4]</td>";
print " <td>$data[5]</td>";
print " <td>$data[1]</td>";
print "<td>";
print '<form><center>';
print checkbox(
-name => 'delete',
-value => 'data[0]',
-selected => 0,
-label => 'delete'
);
print '<center></form>';
print "</td>";
print "</tr>";
}
I just do not understand how I can make it delete a row if a checkbox is checked.
i believe your call to checkbox needs to be tweaked a bit:
then in your cgi or object:
will get you the rows to delete by id and then you just build & run your delete statement.