Re: [PHP] Variable variable using constant
> $var = constant('DESKTOP_URL_' . $_SESSION['lang']); Very nice, thank you. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable variable using constant
On 10/12/11 11:51, "Marc Guay" wrote: >Let's say that I have 2 constants > >DEFINE('DESKTOP_URL_en', "http://www.website.com/index.php?page=home";); >DEFINE('DESKTOP_URL_fr', >"http://www.website.com/index.php?page=accueil";); > >and I would like to populate the value of an href with them depending >on the user's language. $_SESSION['lang'] is either 'en' or 'fr'. >How would I go about referring to this variable? Try: $var = constant('DESKTOP_URL_' . $_SESSION['lang']); Regards, Bob -- Robert E. Williams, Jr. Associate Vice President of Software Development Newtek Businesss Services, Inc. -- The Small Business Authority https://www.newtekreferrals.com/rewjr http://www.thesba.com/ Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or if you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variable variable names...
There's a number of things you can do with variable variables... they're quite powerful, I like 'em a lot. :) Anyway, you can do This would output stuff I think that's what you were asking... You've got to use the { and } around the variables you're using to make teh variable variable. --Jason -- 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]
Re: [PHP] Variable variable names...
turns out my subject was right on anyone interested check this page out. http://www.phpbuilder.com/manual/language.variables.variable.php ""Brian Weisenthal"" <[EMAIL PROTECTED]> wrote in message 9h02nm$n7c$[EMAIL PROTECTED]">news:9h02nm$n7c$[EMAIL PROTECTED]... > let say i wanted to see if a variable existed by the name of $myvar2 . how > can i make the '2' come from a variable. so i want to say something like > $myvar$othervar .(but obviously that wont work) anyone have a clue? i tried > using eval but i couldn't get it right > > > > > -- > 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]
RE: [PHP] Variable Variable
http://www.php.net/manual/en/language.variables.variable.php -Original Message- From: Brandon Orther [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 4:53 PM To: PHP User Group Subject: [PHP] Variable Variable Hello, I can't find Variable Variable in the php manual. If someone has a link to the section in the PHP manual about this please send me a link. Thank you, Brandon Orther -- 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]
Re: [PHP] Variable Variable with array
are you thinking of what this snippet does: $menu = 'menu2'; $i = 2; echo ${$menu}[$i]; - Original Message - From: "Brandon Orther" <[EMAIL PROTECTED]> To: "PHP User Group" <[EMAIL PROTECTED]> Sent: 2001. május 7. 22:16 Subject: [PHP] Variable Variable with array > Hello, > > I am trying to use variable variable. with arrays. this may be hard to > understand so here is an example: > > $menu1[0] = "1"; > $menu1[1] = "2"; > $menu1[2] = "3"; > > $menu2[0] = "1"; > $menu2[1] = "2"; > $menu2[2] = "3"; > > $menu3[0] = "1"; > $menu3[1] = "2"; > $menu3[2] = "3"; > > does anyone know the proper way to use variable variable with arrays? > > Thanks > > Brandon > > > -- > 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]
Re: [PHP] Variable variable
> The braces aren't required in this case. Yup, your right. I stand corrected. I had forgotten that multiple $s are fine, and that I simply don't use them because I have trouble reading them. The joys of learning ;\ -- Plutarck Should be working on something... ...but forgot what it was. ""Steve Werby"" <[EMAIL PROTECTED]> wrote in message 001e01c0c80e$45410400$6501a8c0@workstation7">news:001e01c0c80e$45410400$6501a8c0@workstation7... > "Plutarck" <[EMAIL PROTECTED]> wrote: > > Your problem has little to do with the things mentioned. > > > > First of all, you are refering to a variable variable incorrectly. > > Actually, he's not. > > >You must > > use brackets, like this: > > > > ${$id} > > The braces aren't required in this case. Of the four examples below, only > the 3rd won't return the expected results - because the first $ is > interpreted as a literal $. Paste the code below into a webpage and see for > yourself. > > $field = 'name'; > $name = 'Steve'; > > echo '' . $$field; > echo '' . ${$field}; > echo '' . "My name is $$field."; > echo '' . "My name is ${$field}."; > ?> > > I have a few possible explanations for the problem of the original poster > (see below). > > > if (${$id} == "on") > > { > > echo 'on'; > > } else > > { > > echo 'off'; > > } > > 1. If $id is a number I believe PHP will choke b/c I don't believe numbers > can be used as variable names. > > 2. Assume $id = 'age_bracket'. The control structure checks to see if > $age_bracket == "on". To set $id in the first place for your multiple > checkbox values, you'd have to loop through the values sent from the form. > Jack (original poster), did you do that? If your form's method = post then > you would loop through $HTTP_POST_VARS and if it was get $HTTP_GET_VARS (and > then only loop through the checkbox variables). Or you could predefine the > checkbox variables using: > > $checkbox_fields = array( 'age_bracket', 'weight', 'gender', 'occupation' ); > > And then loop through as follows: > > while( list( , $val ) = each( $checkbox_fields ) ) > { > // may have to set as $$GLOBALS[$val] if within a function or declare $val > as global first. > if ( $$val == 'on' ) > { > echo 'on'; > } > else > { > echo 'off'; > } > } > > -- > Steve Werby > President, Befriend Internet Services LLC > http://www.befriend.com/ > > > -- > 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]
Re: [PHP] Variable variable
> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote: > > > 1. If $id is a number I believe PHP will choke b/c I don't believe > numbers > > > can be used as variable names. > > > > Well, generally that is true. If you try to assign a value directly to a > > variable that is a number such as: > > > > $1 = "Hello World"; > > > > Then it won't work. However, due to a somewhat quirky implementation you > > can get arund this by doing: > > > > $a=1; > > $$a = "Hello World"; > > Sure enough, it works. Rasmus, can we expect this behavior to exist in > future releases of PHP? I prefer to give variables a meaningful name, but > since I spend a fair amount of time working with other people's code and > clients who sometimes insist on things that aren't preferable, it would be > nice to know. Writing code that relies on this behaviour is a bad idea. It is unlikely to change in PHP 4, but who knows what will happen in the longer term... -Rasmus -- 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]
Re: [PHP] Variable variable
"Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote: > > 1. If $id is a number I believe PHP will choke b/c I don't believe numbers > > can be used as variable names. > > Well, generally that is true. If you try to assign a value directly to a > variable that is a number such as: > > $1 = "Hello World"; > > Then it won't work. However, due to a somewhat quirky implementation you > can get arund this by doing: > > $a=1; > $$a = "Hello World"; Sure enough, it works. Rasmus, can we expect this behavior to exist in future releases of PHP? I prefer to give variables a meaningful name, but since I spend a fair amount of time working with other people's code and clients who sometimes insist on things that aren't preferable, it would be nice to know. -- Steve Werby President, Befriend Internet Services LLC http://www.befriend.com/ -- 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]
Re: [PHP] Variable variable
> 1. If $id is a number I believe PHP will choke b/c I don't believe numbers > can be used as variable names. Well, generally that is true. If you try to assign a value directly to a variable that is a number such as: $1 = "Hello World"; Then it won't work. However, due to a somewhat quirky implementation you can get arund this by doing: $a=1; $$a = "Hello World"; You can verify that you do indeed have a variable named $1 in your global symbol table by doing: echo $GLOBALS[1]; -Rasmus -- 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]
Re: [PHP] Variable variable
"Plutarck" <[EMAIL PROTECTED]> wrote: > Your problem has little to do with the things mentioned. > > First of all, you are refering to a variable variable incorrectly. Actually, he's not. >You must > use brackets, like this: > > ${$id} The braces aren't required in this case. Of the four examples below, only the 3rd won't return the expected results - because the first $ is interpreted as a literal $. Paste the code below into a webpage and see for yourself. ' . $$field; echo '' . ${$field}; echo '' . "My name is $$field."; echo '' . "My name is ${$field}."; ?> I have a few possible explanations for the problem of the original poster (see below). > if (${$id} == "on") > { > echo 'on'; > } else > { > echo 'off'; > } 1. If $id is a number I believe PHP will choke b/c I don't believe numbers can be used as variable names. 2. Assume $id = 'age_bracket'. The control structure checks to see if $age_bracket == "on". To set $id in the first place for your multiple checkbox values, you'd have to loop through the values sent from the form. Jack (original poster), did you do that? If your form's method = post then you would loop through $HTTP_POST_VARS and if it was get $HTTP_GET_VARS (and then only loop through the checkbox variables). Or you could predefine the checkbox variables using: $checkbox_fields = array( 'age_bracket', 'weight', 'gender', 'occupation' ); And then loop through as follows: while( list( , $val ) = each( $checkbox_fields ) ) { // may have to set as $$GLOBALS[$val] if within a function or declare $val as global first. if ( $$val == 'on' ) { echo 'on'; } else { echo 'off'; } } -- Steve Werby President, Befriend Internet Services LLC http://www.befriend.com/ -- 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]
Re: [PHP] Variable variable
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, 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]
Re: [PHP] Variable variable
Sorry - try $HTTP_POST_VARS Chris Jacky wrote: > I did look up in the manual for $HTTP_GET_VARS but could not find it? what > is it? a function? > sorry to ask this again, just try to find out how to use that. > Jack > [EMAIL PROTECTED] > "There is nothing more rewarding than reaching the goal you set for > yourself" > - Original Message - > From: Chris Fry <[EMAIL PROTECTED]> > To: Jacky <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Wednesday, April 18, 2001 2:59 AM > Subject: Re: [PHP] Variable variable > > > Sorry - thought you only had one! - it's late. > > > > To Name the checkboxes you need: > > > while (get records from db) { > > $id = id from record; > > ?> > > > > > } > > ?> > > > > You would have to do a $HTTP_GET_VARS on the next page to find out which > ones > > exist. > > > > Then your select statement would be: > > > > $query = "select * from table where id IN ('comma delimited list of > values')"; > > > > Messy but do-able! > > > > Probably a better way - There usually is! > > > > Chris > > > > Jacky wrote: > > > > > so how do I check at the next page which one is checked? > > > Jack > > > [EMAIL PROTECTED] > > > "There is nothing more rewarding than reaching the goal you set for > > > yourself" > > > - Original Message - > > > From: Chris Fry <[EMAIL PROTECTED]> > > > To: Jacky <[EMAIL PROTECTED]> > > > Cc: <[EMAIL PROTECTED]> > > > Sent: Wednesday, April 18, 2001 2:31 AM > > > Subject: Re: [PHP] Variable variable > > > > > > > Jacky, > > > > > > > > You do not need the value. The variable $id will either exist (if the > user > > > checked it) or not (if the user did not check it). > > > > > > > > Hope this helps. > > > > > > > > Chris > > > > > > > > Jacky wrote: > > > > > > > > > Hi all > > > > > I have a form with check box and name of those checkboxes is usuing > > > variable lke this, > > > > > > > > > > > > > > > > > > > > > > > > > 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" > > > > > > > > -- > > > > Chris Fry > > > > Quillsoft Pty Ltd > > > > Specialists in Secure Internet Services and E-Commerce Solutions > > > > 10 Gray Street > > > > Kogarah > > > > NSW 2217 > > > > Australia > > > > > > > > Phone: +61 2 9553 1691 > > > > Fax: +61 2 9553 1692 > > > > Mobile: 0419 414 323 > > > > eMail: [EMAIL PROTECTED] > > > > http://www.quillsoft.com.au > > > > > > > > You can download our Public CA Certificate from:- > > > > https://ca.secureanywhere.com/htdocs/cacert.crt > > > > > > > > ** > > > > > > > > This information contains confidential information intended only for > > > > the use of the authorised recipient. If you are not an authorised > > > > recipient of this e-mail, please contact Quillsoft Pty Ltd by return > > > > e-mail. > > > > In this case, you should not read, print, re-transmit, store or act > > > > in reliance on this e-mail or any attachments, and should destroy all > > > > copies of them. > > > > This e-mail and any attachments may als
Re: [PHP] Variable variable
I did look up in the manual for $HTTP_GET_VARS but could not find it? what is it? a function? sorry to ask this again, just try to find out how to use that. Jack [EMAIL PROTECTED] "There is nothing more rewarding than reaching the goal you set for yourself" - Original Message - From: Chris Fry <[EMAIL PROTECTED]> To: Jacky <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, April 18, 2001 2:59 AM Subject: Re: [PHP] Variable variable > Sorry - thought you only had one! - it's late. > > To Name the checkboxes you need: > while (get records from db) { > $id = id from record; > ?> > > } > ?> > > You would have to do a $HTTP_GET_VARS on the next page to find out which ones > exist. > > Then your select statement would be: > > $query = "select * from table where id IN ('comma delimited list of values')"; > > Messy but do-able! > > Probably a better way - There usually is! > > Chris > > Jacky wrote: > > > so how do I check at the next page which one is checked? > > Jack > > [EMAIL PROTECTED] > > "There is nothing more rewarding than reaching the goal you set for > > yourself" > > - Original Message ----- > > From: Chris Fry <[EMAIL PROTECTED]> > > To: Jacky <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]> > > Sent: Wednesday, April 18, 2001 2:31 AM > > Subject: Re: [PHP] Variable variable > > > > > Jacky, > > > > > > You do not need the value. The variable $id will either exist (if the user > > checked it) or not (if the user did not check it). > > > > > > Hope this helps. > > > > > > Chris > > > > > > Jacky wrote: > > > > > > > Hi all > > > > I have a form with check box and name of those checkboxes is usuing > > variable lke this, > > > > > > > > > > > > > > > > > > > > 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" > > > > > > -- > > > Chris Fry > > > Quillsoft Pty Ltd > > > Specialists in Secure Internet Services and E-Commerce Solutions > > > 10 Gray Street > > > Kogarah > > > NSW 2217 > > > Australia > > > > > > Phone: +61 2 9553 1691 > > > Fax: +61 2 9553 1692 > > > Mobile: 0419 414 323 > > > eMail: [EMAIL PROTECTED] > > > http://www.quillsoft.com.au > > > > > > You can download our Public CA Certificate from:- > > > https://ca.secureanywhere.com/htdocs/cacert.crt > > > > > > ** > > > > > > This information contains confidential information intended only for > > > the use of the authorised recipient. If you are not an authorised > > > recipient of this e-mail, please contact Quillsoft Pty Ltd by return > > > e-mail. > > > In this case, you should not read, print, re-transmit, store or act > > > in reliance on this e-mail or any attachments, and should destroy all > > > copies of them. > > > This e-mail and any attachments may also contain copyright material > > > belonging to Quillsoft Pty Ltd. > > > The views expressed in this e-mail or attachments are the views of > > > the author and not the views of Quillsoft Pty Ltd. > > > You should only deal with the material contained in this e-mail if > > > you are authorised to do so. > > > > > > This notice should not be removed. > > > > > > > > > > > > -- > > > 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 administr
Re: [PHP] Variable variable
Sorry - thought you only had one! - it's late. To Name the checkboxes you need: You would have to do a $HTTP_GET_VARS on the next page to find out which ones exist. Then your select statement would be: $query = "select * from table where id IN ('comma delimited list of values')"; Messy but do-able! Probably a better way - There usually is! Chris Jacky wrote: > so how do I check at the next page which one is checked? > Jack > [EMAIL PROTECTED] > "There is nothing more rewarding than reaching the goal you set for > yourself" > - Original Message - > From: Chris Fry <[EMAIL PROTECTED]> > To: Jacky <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Wednesday, April 18, 2001 2:31 AM > Subject: Re: [PHP] Variable variable > > > Jacky, > > > > You do not need the value. The variable $id will either exist (if the user > checked it) or not (if the user did not check it). > > > > Hope this helps. > > > > Chris > > > > Jacky wrote: > > > > > Hi all > > > I have a form with check box and name of those checkboxes is usuing > variable lke this, > > > > > > > > > > > > > > > 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" > > > > -- > > Chris Fry > > Quillsoft Pty Ltd > > Specialists in Secure Internet Services and E-Commerce Solutions > > 10 Gray Street > > Kogarah > > NSW 2217 > > Australia > > > > Phone: +61 2 9553 1691 > > Fax: +61 2 9553 1692 > > Mobile: 0419 414 323 > > eMail: [EMAIL PROTECTED] > > http://www.quillsoft.com.au > > > > You can download our Public CA Certificate from:- > > https://ca.secureanywhere.com/htdocs/cacert.crt > > > > ** > > > > This information contains confidential information intended only for > > the use of the authorised recipient. If you are not an authorised > > recipient of this e-mail, please contact Quillsoft Pty Ltd by return > > e-mail. > > In this case, you should not read, print, re-transmit, store or act > > in reliance on this e-mail or any attachments, and should destroy all > > copies of them. > > This e-mail and any attachments may also contain copyright material > > belonging to Quillsoft Pty Ltd. > > The views expressed in this e-mail or attachments are the views of > > the author and not the views of Quillsoft Pty Ltd. > > You should only deal with the material contained in this e-mail if > > you are authorised to do so. > > > > This notice should not be removed. > > > > > > > > -- > > 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] -- Chris Fry Quillsoft Pty Ltd Specialists in Secure Internet Services and E-Commerce Solutions 10 Gray Street Kogarah NSW 2217 Australia Phone: +61 2 9553 1691 Fax: +61 2 9553 1692 Mobile: 0419 414 323 eMail: [EMAIL PROTECTED] http://www.quillsoft.com.au You can download our Public CA Certificate from:- https://ca.secureanywhere.com/htdocs/cacert.crt ** This information contains confidential information intended only for the use of the authorised recipient. If you are not an authorised recipient of this e-mail, please contact Quillsoft Pty Ltd by return e-mail. In this case, you should not read, print, re-transmit, store or act in reliance on this e-mail or any attachments, and should destroy all copies of them. This e-mail and any attachments may also contain copyright material belonging to Quillsoft Pty Ltd. The views expressed in this e-mail or attachments are the views of the author and not the views of Quillsoft Pty Ltd. You should only deal with the material contained in this e-mail if you are authorised to do so. This notice should not be removed. -- 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]
Re: [PHP] Variable variable
so how do I check at the next page which one is checked? Jack [EMAIL PROTECTED] "There is nothing more rewarding than reaching the goal you set for yourself" - Original Message - From: Chris Fry <[EMAIL PROTECTED]> To: Jacky <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, April 18, 2001 2:31 AM Subject: Re: [PHP] Variable variable > Jacky, > > You do not need the value. The variable $id will either exist (if the user checked it) or not (if the user did not check it). > > Hope this helps. > > Chris > > Jacky wrote: > > > Hi all > > I have a form with check box and name of those checkboxes is usuing variable lke this, > > > > > > > > > > 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" > > -- > Chris Fry > Quillsoft Pty Ltd > Specialists in Secure Internet Services and E-Commerce Solutions > 10 Gray Street > Kogarah > NSW 2217 > Australia > > Phone: +61 2 9553 1691 > Fax: +61 2 9553 1692 > Mobile: 0419 414 323 > eMail: [EMAIL PROTECTED] > http://www.quillsoft.com.au > > You can download our Public CA Certificate from:- > https://ca.secureanywhere.com/htdocs/cacert.crt > > ** > > This information contains confidential information intended only for > the use of the authorised recipient. If you are not an authorised > recipient of this e-mail, please contact Quillsoft Pty Ltd by return > e-mail. > In this case, you should not read, print, re-transmit, store or act > in reliance on this e-mail or any attachments, and should destroy all > copies of them. > This e-mail and any attachments may also contain copyright material > belonging to Quillsoft Pty Ltd. > The views expressed in this e-mail or attachments are the views of > the author and not the views of Quillsoft Pty Ltd. > You should only deal with the material contained in this e-mail if > you are authorised to do so. > > This notice should not be removed. > > > > -- > 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]
Re: [PHP] Variable variable
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: > > > > > > > > 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]
Re: [PHP] Variable variable
Jacky, You do not need the value. The variable $id will either exist (if the user checked it) or not (if the user did not check it). Hope this helps. Chris Jacky wrote: > Hi all > I have a form with check box and name of those checkboxes is usuing variable lke >this, > > > > > 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" -- Chris Fry Quillsoft Pty Ltd Specialists in Secure Internet Services and E-Commerce Solutions 10 Gray Street Kogarah NSW 2217 Australia Phone: +61 2 9553 1691 Fax: +61 2 9553 1692 Mobile: 0419 414 323 eMail: [EMAIL PROTECTED] http://www.quillsoft.com.au You can download our Public CA Certificate from:- https://ca.secureanywhere.com/htdocs/cacert.crt ** This information contains confidential information intended only for the use of the authorised recipient. If you are not an authorised recipient of this e-mail, please contact Quillsoft Pty Ltd by return e-mail. In this case, you should not read, print, re-transmit, store or act in reliance on this e-mail or any attachments, and should destroy all copies of them. This e-mail and any attachments may also contain copyright material belonging to Quillsoft Pty Ltd. The views expressed in this e-mail or attachments are the views of the author and not the views of Quillsoft Pty Ltd. You should only deal with the material contained in this e-mail if you are authorised to do so. This notice should not be removed. -- 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]
Re: [PHP] Variable variable
Jacky schrieb: > > > > 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]