function problem
| From: | Peter Gumbrell | Date: | Fri, 14 Feb 2003 23:11:38 +0000 |
| Subject: | function problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-135613@lists.php.net to get a copy of this message | ||
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