multiple function returns

From: Date: Thu, 25 Jan 2001 05:04:27 +0000
Subject: multiple function returns
Groups: php.general 
Request: Send a blank email to php-general+get-36567@lists.php.net to get a copy of this message
Can anyone help me I'm trying to read two results from a function by passing them out via an array but I'm not sure how to access them once I have done that. In the PHP manual it shows a list call which I can't seem to even find what the hell it does the code below runs without any errors but does not seem to work. here the function gest passed the language and currency preference and a variable (1,0) to decide what it will do with them - update the preferences of the user or read out and define the preferences. (once updated I want it to read out the prefs aswell) function PrefChange($lang,$curry,$state){ global $DB_Server, $HTTP_Host, $DB_Login, $DB_Password, $DB_Name, $DocRoot ; if ($state){//read preferences from page if (!($result = mysql_db_query($DB_Name,"SELECT language_pref, currency_pref FROM users WHERE user_id ='$cookie_user'"))){ DisplayErrMessage(sprintf("internal error %s %s %s %d:%s\n",$DB_Server, $DB_Login, $DB_Password, mysql_errno(), mysql_error())); while ($row = mysql_fetch_array($results)){ $lang_pref = $row["language_pref"]; $currancy_pref = $row["currency_pref"]; return array($lang_pref,$currancy_pref); } } } else {///update preferences from page if (!($result = mysql_db_query($DB_Name,"UPDATE users SET language_pref='$lang' AND currency_pref='$curry' WHERE user_id='$cookie_user'"))){ DisplayErrMessage(sprintf("internal error %s %s %s %d:%s\n",$DB_Server, $DB_Login, $DB_Password, mysql_errno(), mysql_error())); PrefChange(0,0,1) ; } } } an example of what I'd like to do when calling the function (here I'm only reading the prefrences from the DB ), a select box that is showing the preference that is chosen with the preference read from the above function and the list created by the function below <select name="form_lang_pref" style="font-family:verdana, Arial;font-size:8pt" CLASS:menu"> <? list ($form_language_pref, $form_currency_pref) = PrefChange(0,0,1); $select_id = $form_language_pref; $db = mysql_connect("$DB_Server", "$DB_Login, $DB_Password"); mysql_select_db("$DB_Name",$db); $results = mysql_query("SELECT * FROM language ORDER BY language ",$db); while ($row = mysql_fetch_array($results)){ $rowid = $row["language_id"]; $name = $row["language"]; if ($rowid == $select_id) { echo("<option SELECTED value=\"$id\">$name</option>\n"); } else { echo("<option value=\"$id\">$name</option>\n"); } // endwhile; } echo("</select>"); ?>

« previous php.general (#36567) next »