Your problem has little to do with the things mentioned.
First of all, you are refering to a variable variable incorrectly. You must
use brackets, like this:
${$id}
If ID has the value "Blue", then the above is the same as:
$Blue
So in your examble if you had the checkbox with the value "on", and you want
to see if it was checked, use this:
if (${$id} == "on")
{
echo 'on';
} else
{
echo 'off';
}
But that's an overly complicated way of doing it if you know the "name" of
the checkbox. If the name of the checkbox is "id", then use this piece of
code to access it if it was submitted via POST or GET (which works even if
register_globals is turned off):
$f = 'HTTP_' . $HTTP_ENV_VARS["REQUEST_METHOD"] . '_VARS';
if (${$f}["id"] == "on")
{
echo 'The checkbox with the name "id" has the value "on"';
} else
{
echo "The checkbox with the name "id" was not selected";
}
But if register globals was on, all you have to use is:
if ($id == "on")
{
echo 'The checkbox with the name "id" has the value "on"';
} else
{
echo "The checkbox with the name "id" was not selected";
}
Tell me if that doesn't answer your questions.
--
Plutarck
Should be working on something...
...but forgot what it was.
""Jacky"" <[EMAIL PROTECTED]> wrote in message
011001c0c839$ebfb9b40$[EMAIL PROTECTED]">news:011001c0c839$ebfb9b40$[EMAIL PROTECTED]...
Hi all
I have a form with check box and name of those checkboxes is usuing variable
lke this,
<!-- 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";
}
It always returns echo "off", why is that?
cheers
Jack
[EMAIL PROTECTED]
"There is nothing more rewarding than reaching the goal you set for
yourself"
--
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]