Solved

foreach checkboxes checked

Posted on 2011-03-10
4
693 Views
Last Modified: 2012-05-11
in a form, how to

foreach checkboxes checked{
do something to row1
do something to row2
do something to row3
}
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:Doug Walton
ID: 35098666
Depending on how you're sending the form you might want something like this:
$checkbox1 = $_POST['name of checkbox1'];
if (isset($checkbox1))
{
  //do something for checkbox1
}

Open in new window

Then repeat for each box.

Is that what you're looking for?
0
 

Author Comment

by:rgb192
ID: 35099382
so would this work

if (isset($checkbox[]))
0
 
LVL 4

Accepted Solution

by:
Doug Walton earned 500 total points
ID: 35099606
Probably, if you want to store the checkbox values in an array you could do something like that.

$checkbox[0] = $_POST['input name of checkbox'];
$checkbox[1] = $_POST['input name of checkbox'];
...
for($i = 0; $i < count($checkbox); $i++)
{
  if (isset($checkbox[$i]))
  {
    //do something
  }
}

Open in new window


That would do that same thing for each checkbox.  If you want to do something different for each one, you could take it out of the for-loop.

Does that help?
0
 

Author Closing Comment

by:rgb192
ID: 35152616
thanks
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question