Exactly where does $option_block get put into $string? -Kevin ----- Original Message ----- From: "Peter Gumbrell" <[EMAIL PROTECTED]> To: "Php-General" <[EMAIL PROTECTED]> Sent: Friday, February 14, 2003 4:11 PM Subject: [PHP] function problem
> I have a function below which populates a select list, based on the query > string and the field name. It then prints a string: > > function populate_selects($query_name, $db_field, $link, $string) > { > $result = mysql_query($query_name, $link) or die ("Could not execute > query."); > while ($columns = mysql_fetch_array($result)) > { > $column = $columns[$db_field]; > global $option_block; > $option_block .= "<OPTION name='vendor1' > value=\"$column\">$column</OPTION>\n"; > } > print $string; > } > > Part of the string that is printed in $string is the $option_block which is > in the function. There seems to be some problem with scope here. I made the > $option_block variable global but it still won't print. I have tested that > the $column field is being populated and it is, so I believe that it must be > the $option_block part that isn't working. Does anyone have any suggestions? > > Peter Gumbrell > [EMAIL PROTECTED] > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php