Posts: 1,832
Location: Somewhere else entirely
|
Heres a short script I wrote that should illustrate a nice easy way of doing this:
PHP Code:
<html>
<body>
<?php
if(isset($_POST['submit'])) {
echo"<pre>\n";
print_r($_POST);
echo"<\pre>\n";
}
else {
echo "<form action='".$SERVER['PHP_SELF']."' method='POST'>";
for($i=0; $i<50; $i++) {
echo "<input type='checkbox' name='boxes[$i]' /><br />";
}
echo '<input type="submit" name="submit" value="Go" />';
echo "</form>";
}
?>
</body>
</html>
Code:
Array
(
[boxes] => Array
(
[9] => on
[14] => on
[18] => on
[22] => on
[23] => on
[26] => on
[28] => on
[32] => on
)
[submit] => Go
)
You can create the checkboxes with the name boxes[0], boxes[1] etc, then when you read the post variables after the form is submitted, you get one array called boxes, with all the indexes of the boxes you ticked set to on.
You can then do something like
PHP Code:
foreach($boxes as $key => $value) {
echo "Processing checkbox $key<br />";
}
which would print
Code:
Processing checkbox 9
Processing checkbox 14
Processing checkbox 18
Processing checkbox 22
Processing checkbox 23
Processing checkbox 26
Processing checkbox 28
Processing checkbox 32
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Please login or register to view this content. Registration is FREE (aka MSN handwriting for forums)
|