Jump to content

[SOLVED] Form help required... apply within.


defeated

Recommended Posts

I want to do something and I have no idea how to go about it.

 

I am displaying the contents of my db out into a table. Each line of the table is a result row from mysql with its own id.  I have added a column of checkboxes to the side of the table.

 

I want to be able to select x number of rows via the check boxes and then click a button that sends information to a page to delete all those rows with checked check boxes.

 

Logic has escaped me.

 

I guess I want to turn the table into a form and return an array of all the row id's that are checked...  that way I can do a foreach on the array to delete each one. ???

 

Am I barking up the wrong tree?

 

How would you do it?

Link to comment
https://forums.phpfreaks.com/topic/154205-solved-form-help-required-apply-within/
Share on other sites

ok, but how do I assign the row id value to the checkbox?

 

echo "<tr><td>".$id."</td><td>".$name."</td><td>".$subject."</td>";
echo "<td><input type='checkbox' name='whatever' /></td></tr>";
echo "<input type='hidden' name='row' value='".$id."' />

how do I associate the checkbox with that particular row?

Just a quick note, to get an array returned as the post data set the name field on each of your checkboxes like name="NAME[]" where NAME is the name of the field. The square brackets should make $_POST[NAME] return an array (note that you should still sanity check it before attempting processing in case none are selected).

 

Just seen your update, like this:

echo "<tr><td>".$id."</td><td>".$name."</td><td>".$subject."</td>";
echo "<td><input type='checkbox' name='whatever[]' value=".$id."/></td></tr>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.