Re: PHP Coding Question

From: Date: Thu, 26 Oct 2000 05:00:14 +0000
Subject: Re: PHP Coding Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22049@lists.php.net to get a copy of this message
On Wed, 25 Oct 2000, Kyle Mathews wrote: > Ok, this is what I'm trying to do. > > Setup a form with about 20 different check boxes. Now once submitted I need > the values of the boxes that were checked to go into an array. I need this > so that I can later dump the values, in a clean manner, to a printable page. > > Is there an efficient way to do this, and if so could someone give me some > example code? Well, here's some example code. <? if ($action == "Check") { echo 'Boxes checked:<ul>'; foreach ($boxes as $box) echo "<li> $box"; } else { echo '<form method="post" action="' . $PHP_SELF . '">'; for ($i = 1; $i < 21; $i++ ) echo '<input type="checkbox" name="boxes[]" value="' . $i . '"> Box ' . $i . '<br>'; echo '<input type="submit" name="action" value="Check"></form>'; } ?> Outputs 20 checkboxes, and tells you which ones you checked. Matt

« previous php.general (#22049) next »