Solved

foreach checkboxes checked

Posted on 2011-03-10
4
680 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
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:Doug Walton
Comment Utility
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
Comment Utility
so would this work

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

Accepted Solution

by:
Doug Walton earned 500 total points
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now