Just when I start thinking I'm all clever!
I put together a little script (comOpts.php) which outputs the following source code
(which is what I'm after--sort of) thinking I would then call it into "makeComBox.php" using
"include_once('comOpts.php')", but of course that doesn't work.
//view source gets me
$comOpts1="
<option value='Select Option'>Select Option</option>
<option value='Red'>Red</option>
<option value='Green'>Green</option>
<option value='Blue'>Blue</option>
";
$comOpts2="
<option value='Select Option'>Select Option</option>
<option value='Cyan'>Cyan</option>
<option value='Magenta'>Magenta</option>
<option value='Yellow'>Yellow</option>
";
Please, how might modify "comOpts.php" to pass the $variables (as output above) into the file "makeComBox.php" OR otherwise CALL the variables into makeComBox.php from "comOpts.php"
<?php //comOpts.php
$colorOpt=array(
array("Select Option",
"Red",
"Green",
"Blue"
),
array("Select Option",
"Cyan",
"Magenta",
"Yellow"
)
);
$row_count = count($colorOpt);
for ($row = 0; $row < $row_count; $row++)
{
$name='$'.'comOpts';
$optCount=$row+1;
$optName=$name.$optCount;
$option = $optName.'="';
$option .= "\r\n";
foreach($colorOpt[$row] as $key => $value)
{
$option .= "\t".'<option value=\''.$value.'\'>' . $value.'</option>'."\r\n";
}
$option .= '";'."\r\n ";
echo $option;
}
?>