Jump to content

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>";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.