Re: function problem

From: Date: Fri, 14 Feb 2003 23:41:06 +0000
Subject: Re: function problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-135615@lists.php.net to get a copy of this message
Exactly where does $option_block get put into $string? -Kevin ----- Original Message ----- From: "Peter Gumbrell" <peter@orillia.net> To: "Php-General" <php-general@lists.php.net> 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 > peter@orillia.net > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#135615) next »