Re: [SOLVED] Re: usr VAR value as a VAR Name
| From: | Barry | Date: | Thu, 26 Jan 2006 14:36:50 +0000 |
| Subject: | Re: [SOLVED] Re: usr VAR value as a VAR Name | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229311@lists.php.net to get a copy of this message | ||
Barry wrote:
Fernando Anchorena wrote:Barry wrote:echo $$foo GreetsFernando Anchorena wrote:Thx for your answer Berry, What if I don't know the value of "$foo " (witch is "bar") so we have this : $foo = "UnKnowName"; $$foo = "Hello World!"; Here is the problem // remember that I dont know the value of $foo echo .'$'.$foo // prints out $UnKnowName but I need to prints out Hello Worlds! so If I don'r know the value of $foo, what can I do tu prints out Hello World! Thx in advance.Fisrt thx to all for yours answers, I'm updating the mail because in hte last mail I'didn express my self correctly : EXAMPLE page1.php ======================================= <form action="/page2.php?form=yes" method="post">Small example that might help solve it: $foo = "bar"; $$foo = "Hello World!"; echo $bar; // Prints out Hello World! Greets$sql_pro ="SELECT Sid FROM table"; $res_pro = @mysql_query( $sql_pro); while ($campo_pro = @mysql_fetch_array($res_pro)) { $sid_pro = $campo_pro["Sid"]; // $sid_pro = 4 $sid_pro = 'p'.$sid_pro; // I'm trying to use the value of $sid_pro as a VAR name *$sid_pro = p4* print "<td ><input name='$sid_pro' type= 'radio' // Here the Imput Name is a VALUE from Database value='AAAA'/>* </td>"; // *name = p4 * BLA BLA BLA }page2.php // I Need to access a value from the form witch it's stored in a VAR called $p4 // The Name of the VAR "$p4" It's stored in my database, so How can I convert a database string to a VAR NAME ======================================= $sqlname = "SELECT Sid FROM Table"; $res = mysql_query ($sqlname) ; while ($campo_pro = mysql_fetch_array($res)) {$name1 = $campo_pro["Sid"]; // *$name1 = 4* $radio = '$'.'p'.$name1 ; // *$radio = $p4 ---------------------- Now the Problem **How can I get the Value SOLVE_ME from the submited form ?* echo '$radio'; // == $p4 => WRONG i need AAAA // The VALUE of $radio witch is "$p4" is the name of the VAR I need to access, how can I export the VALUE "$p4" AS a VAR Name ?}BarryBarry