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
[EMAIL PROTECTED]
"There is nothing more rewarding than reaching the goal you set for
yourself"
----- Original Message -----
From: Ulf Wendel <[EMAIL PROTECTED]>
To: Jacky <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to