selecting from an array based on form content
| From: | Peter Gumbrell | Date: | Sun, 02 Feb 2003 17:04:47 +0000 |
| Subject: | selecting from an array based on form content | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134007@lists.php.net to get a copy of this message | ||
The following code loops through a multidimensional array, printing the
subject heading and then the strand:
foreach( $strandx as $subjectx=>$strandy )
{
print " <li><b>".$subjectx."</b>.<br />\n";
print " <ul>\n";
asort( $strandy ); // sorts the strands
foreach( $strandy as $str )
{ print "<li>";
checkbox("fstrand[]",$subjectx,$str,0,0);
print "</li>\n";
}
print " </ul>\n";
}
print "</ol>\n";
This is the array so far:
$strandx = array('English' => array('Reading', 'Writing','Oral
and Visual
Communication'),
'Mathematics' => array('Number Sense and Numeration',
'Measurement',
'Geometry and Spatial Sense','Patterning and Algebra','Data Management and
Probability'));
I would like to limit the subject and strand being printed based on the
subject selected in a form. So, for example, if "English" is selected in the
form, only the subject name and the strands for English would be published.
Could someone please help me with the code for this.
Many thanks,
Peter Gumbrell
peter@orilla.net