What 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
lt);
?>
<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
ckquote>
<?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
Variables.
include on line 21
$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
Start Free Trial