How do I reference outside of my user defined function?
Posted: Fri Sep 27, 2002 10:37 am
I need to reference a global multidimensional array inside my function, but $GLOBALS["CSSArray["$arg_1"]["$arg_2"]"] doesn't seem to work. Has anyone else run into this and solved it?
// function to read the database. it will print out the options
function printOptions($arg_1, $arg_2) {
$query = "SELECT * FROM style WHERE tag = '$arg_1' AND attrib = '$arg_2' ORDER BY val";
$result = mysql_db_query($GLOBALS["db"], $query, $GLOBALS["connection"]);
while($myrow = mysql_fetch_array($result)) {
if ($CSSArray["$arg_1"]["$arg_2"] == $myrow["val"]) {
print " <OPTION SELECTED VALUE=\"" . $myrow["val"] . "\">" . $myrow["val"] . "</OPTION>\n";
} else {
print " <OPTION VALUE=\"" . $myrow["val"] . "\">" . $myrow["val"] . "</OPTION>\n";
}
}
mysql_free_result($result);
}
// function to read the database. it will print out the options
function printOptions($arg_1, $arg_2) {
$query = "SELECT * FROM style WHERE tag = '$arg_1' AND attrib = '$arg_2' ORDER BY val";
$result = mysql_db_query($GLOBALS["db"], $query, $GLOBALS["connection"]);
while($myrow = mysql_fetch_array($result)) {
if ($CSSArray["$arg_1"]["$arg_2"] == $myrow["val"]) {
print " <OPTION SELECTED VALUE=\"" . $myrow["val"] . "\">" . $myrow["val"] . "</OPTION>\n";
} else {
print " <OPTION VALUE=\"" . $myrow["val"] . "\">" . $myrow["val"] . "</OPTION>\n";
}
}
mysql_free_result($result);
}