Re: Variable variable

From: Date: Wed, 18 Apr 2001 19:21:29 +0000
Subject: Re: Variable variable
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-49141@lists.php.net to get a copy of this message
the variable $id in the second sniplet come from the id from talble when I run query and loop it using mysql_fetch_array. So I end up have value of $id from the id field from table, right?But the value store in $id is now in string value, and if I need to use that value for the if..then.. else condition to check if which checkbox is checked, I will need to use Variable variable to make the string back to be variable again , like $$id, for instance after I run the query and get all Id value from table, it will be like $id = 1, $id=2, and so on and as I used this for checkbox name at the previous page, in order to uset it in the if..then..else condition in the second sniplet, it will be like if ($1=="on") { do something }else{ do somehting } but something is wrong here at the if then else bit. But I don't know what is it. Jack jacky@activelifestyle.com "There is nothing more rewarding than reaching the goal you set for yourself" ----- Original Message ----- From: Ulf Wendel <ulf.wendel@phpdoc.de> To: Jacky <jacky@activelifestyle.com> Cc: <php-general@lists.php.net> Sent: Wednesday, April 18, 2001 2:20 AM Subject: Re: [PHP] Variable variable > > > Jacky schrieb: > > <!-- I got the value $id from a table and looping them and assign them to the check box name--> > > <input type="checkbox" name ="$id" value="on"> > > > > and when I submit the form to page foo.php4, at that page, I use Variable variable to call the value of the check box to see if it checked like this > > > > $quey = "select id from table"; > > $result = ...... ( assumeing it is done and i got value for $id for all records from table) > > > > if ($$id =="on"){ > > echo "on"; > > }else{ > > echo "off"; > > } > > What's the value of $id in the second snippet? Generally speaking using > $GLOBALS[$id] gives you more readable code but variable variables. > > Ulf > > -- > Neu: PEAR Menu 3 - Navigationsstrukturen dynamisch dargestellt > http://www.ulf-wendel.de/projekte/menu/tutorial.php | > http://www.phpdoc.de > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#49141) next »