At 10:43 PM -0700 4/16/09, Jim Lucas wrote:
Have your elements setup like such:
<input type="checkbox" name="reserve[rm1]" value="yes" /> Room #1
<input type="checkbox" name="reserve[rm2]" value="yes" /> Room #2
<input type="checkbox" name="reserve[rm3]" value="yes" /> Room #3
<input type="checkbox" name="reserve[rm4]" value="yes" /> Room #4
<input type="checkbox" name="reserve[rm5]" value="yes" /> Room #5
Then on your processing page, you know that you have 5 rooms, 1 - 5.
With this information you can check to make sure that something exists
<?php
$rooms = range(1,5);
for ( $i = 1; $i <= 5; $i++ ) {
if ( isset( $_POST['reserve']['rm'.$i] ) {
# Room was checked
} else {
# Room was NOT checked.
}
}
?>
Jim Lucas
Jim et al:
Try this:
<input type="checkbox" name="reserve[1]" > Room #1
<input type="checkbox" name="reserve[2]" > Room #2
<input type="checkbox" name="reserve[3]" > Room #3
<input type="checkbox" name="reserve[4]" > Room #4
<input type="checkbox" name="reserve[5]" > Room #5
if (isset($_POST['reserve']) )
{
foreach ($_POST['reserve'] as $key => $a)
{
echo("$key $a <br />");
}
}
Here's the demo:
http://www.webbytedd.com/bbbb/post-array1/index.php
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php