Now basically I am trying to set up an easy way to have key value pairs listed in a DB, and then be able to call the name of the key as a variable later in the code of the page and list the corresponding value in the DB. I am almost there. However I just need to figure out some scope issues with functions.
I want to create variables with names on the fly through a function and have them last beyond the life of the function.
However I do not want to have to declare each key/variable as a global variable in the function, will defeat the purpose of this.
I have the following DB table sao_key sao_value app_past_enroll 1 something 0 something_else 1 yet 1
I have the following function
function key_value ( $mysql ) {
if ( $sao_row = $mysql -> fetchRow() ) {
do {
${"$sao_row[0]"} = $sao_row[1]; // Create a variablle to pull the radio variable name
} while ( $sao_row = $mysql -> fetchRow() );
}
}
I have the following code $sql = "SELECT sao_key, sao_value FROM staff_app_options $sao = new MySQL ( $sql ); # Create an object with the above query key_value ( $sao );
echo 'Past Enrollment = ' . $app_past_enroll . NL; echo 'something = ' . $something . NL; echo 'something_else = ' . $something_else . NL; echo 'yet = ' . $yet . NL;
So how do I get the script to read $app_past_enroll as a variable after it has been created by the function?
Thanks for your help.
Phillip
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php