Jump to content

Recommended Posts

the net is always useful where most programming is concerned, you just need to know what you're looking for.  you need to know two things; first, how checkboxes work, and second, how to process arrays.  checkboxes will only send values if they are checked.  if they are unchecked, no variable will even be initialized in the $_POST array.  second, you can name any HTML input as an array, resulting in its value being placed into the relevant sub-array item created in $_POST.  that being said, you can do something like this:

 

ID 1 <input type="checkbox" name="ids_checked[]" value="1" />
ID 2 <input type="checkbox" name="ids_checked[]" value="2" />
ID 3 <input type="checkbox" name="ids_checked[]" value="3" />

 

and in the PHP processing the form input, process through the $_POST['ids_checked'] array:

 

foreach ($_POST['ids_checked'] AS $this_id)
{
  $query = SOME QUERY USING $this_id;
}

 

i'm sure you can expand from there.  if you need to relate that checkbox to a certain set of information (like a row, for example), then use its ID as the index in the other information, and name that as an array:

 

<input type="text" name="title[this_rows_id]" value="some title" />

 

give it a whirl.

Link to comment
https://forums.phpfreaks.com/topic/55301-checkboxes/#findComment-273365
Share on other sites

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.