Thank you!
Okay so I am going to go with your first example. So then on the second page, how to I put commtopic[] into a variable?
Do I use $commtopic[] = $_REQUEST['commtopic[]'];?
Main Topics
Browse All TopicsWhat I am trying to do is have a form that when a user selects a category, then a sub category expands. In the subcategories, they can select any checkbox representing data that they want to be carried over to the next page. I tried to name the checkbox with a number incrementation concatenated behind it. But then I wasn't sure what to do with it on the next page and how to assign it to a variable when I didnt' know the exact name. So if someone can tell me how to do that, that would be great.
Otherwise, I think I have to use an array. But I am not too sure what I am doing wrong with it. I have a loop on my page that puts data into an array called commarray. Then I have a hidden field at that has this array data assigned to it.
In the form this is what I have:
for($i = 0; $i < $commrows; ++$i)
{
$commline = odbc_fetch_array($commresu
?>
<input type='checkbox' name='<?PHP echo 'commtopic'.$i ?>' value='<?PHP echo $commline[Topic] ?>' ><?PHP echo $commline[Topic]; ?> <br>
<div id="<?PHP echo $num ?>" class="switchcontent"><blo
<?PHP
$commarray = array($i => '$commline[Topic]');
?>
</blockquote></div>
<?PHP
}
?>
<input type='hidden' name='commarray' value='<?PHP echo $commarray ?>'>
On the next page, I have the following:
$commarray = $_REQUEST['commarray'];
$arraycount = count($commarray);
//I get an error on this - Warning: array_values(): The argument should be an array in /data/www/html/EROS/Review
$arrayvalues = array_values($commarray);
print "<br>$arrayvalues";
print "<br>$commarray"; //Prints 'Array'
print "<br>$arraycount"; //Prints '1' (when their should be 7)
print "<br>$commarray[0]"; //Prints 'A' - I am not sure where it is getting A from - it is supposed to be a sentence
So I am not sure why this array is not getting passsed to the next page properly. What am I donig wrong?
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
no just
$commtopic = $_REQUEST['commtopic'];
PHP does this convertion automaticly. See http://de3.php.net/manual/
Business Accounts
Answer for Membership
by: hernst42Posted on 2004-12-03 at 14:16:07ID: 12740898
Why not use as name for the checkbox commtopic[], Thus php will automaticly convert all selected checkboxes into an array
lt); ckquote>
$_REQUEST['commtopic'] So you don't need to keep track of how many checkboxes you have printed.
for($i = 0; $i < $commrows; ++$i)
{
$commline = odbc_fetch_array($commresu
?>
<input type='checkbox' name='commtopic[]' value='<?PHP echo $commline[Topic] ?>' ><?PHP echo $commline[Topic]; ?> <br>
<div id="<?PHP echo $num ?>" class="switchcontent"><blo
</blockquote></div>
<?PHP
}
?>
There are also serval issues which do not lead to the expected result:
$commarray = array($i => '$commline[Topic]');
should be
$commarray[$i] => $commline['Topic'];
The ' does not evaluate the variable, and I guess you want to collect all elements
<input type='hidden' name='commarray' value='<?PHP echo $commarray ?>'>
should be
foreach ($commarray as $i => $n) {
?><input type='hidden' name='commarray[<?php echo $i; ?>]' value='<?PHP echo $n;?>'><?php
}
echo array() will print 'Array' not the content/structure of that array THen the code on the second page should work.