to find out which checkbox is checked

From: Date: Wed, 18 Apr 2001 20:19:54 +0000
Subject: to find out which checkbox is checked
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-49151@lists.php.net to get a copy of this message
Hi all, I still cannot get my problem sought out, pretty desparate here so decided to post my question again. Allow me to repeat my question again: I have a form with the checkbox like this <form> <?php $query="select id from foo"; $result=($query,$con); while ($row = mysql_fetch_array($result)) { print("<input type="checkbox" name="$id" value="on">"); } ....submit button and stuffs here... ?> </form> After I submit to next page, at next page, how do I check which check box is checked? I did try isset() and empty() to check if variable exist ( as shown below) and did not work as the result always turn up to be "off" if((empty($id))=='true'){ echo "off"; }else{ echo "on"; } And I also try if(isset($id)) { ..do echo off here... }else{ ...do echo on.... } And the result is always "off" as well. Somene advice me to use $http_var_gets btu I could not find it from manaual, is that the solution I need? cheers Jack jacky@activelifestyle.com "There is nothing more rewarding than reaching the goal you set for yourself" ----- Original Message ----- From: Jacky <jacky@activelifestyle.com> To: Chris Fry <chris@quillsoft.com.au> Cc: <php-general@lists.php.net> Sent: Wednesday, April 18, 2001 2:57 PM Subject: 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 > jacky@activelifestyle.com > "There is nothing more rewarding than reaching the goal you set for > yourself" > ----- Original Message ----- > From: Chris Fry <chris@quillsoft.com.au> > To: Jacky <jacky@activelifestyle.com> > Cc: <php-general@lists.php.net> > 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: > > <?php > > while (get records from db) { > > $id = id from record; > > ?> > > <input type="checkbox" name ="<?php print $id; ?>"> > > <?php > > } > > ?> > > > > 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 > > > jacky@activelifestyle.com > > > "There is nothing more rewarding than reaching the goal you set for > > > yourself" > > > ----- Original Message ----- > > > From: Chris Fry <chris@quillsoft.com.au> > > > To: Jacky <jacky@activelifestyle.com> > > > Cc: <php-general@lists.php.net> > > > 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, > > > > > > > > > > <!-- 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 > > > > > jacky@activelifestyle.com > > > > > "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: chris@quillsoft.com.au > > > > 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: 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 > > > > > > > > > > > > > > -- > > > 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 > > > > -- > > 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: chris@quillsoft.com.au > > 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: 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 > > > > > > > -- > 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 (#49151) next »