Henri,
I think you will need to give some sort of number to each of the checkboxes, e.g.
for($i = 1; $i < 51; $i++)
{
echo "<input type='checkbox' name='lotterynumber".$i."'>";
}
As you are finding, with checkboxes the value returned is either 'on' or null. So
without giving specific names to the checkboxes you will be left with an array of only
those checkboxes that have been checked.
By giving the checkboxes a unique name - based on the numbers - you should then be
able to loop through the checkboxes irrespective of whether they have been checked,
e.g.
for($i = 1; $i < 51; $i ++)
{
if (${lottery_number.$i} == 'on')
echo "The number chosen was $i";
}
You can then determine whether a specific checkbox has been checked by seeing if it
has the value of 'on' and translate this to the number you require.
I think a combination of the code I sent earlier together with that sent by Torsten
will containg the answer.
HTH,
Michael Egan
> -----Original Message-----
> From: Henri Marc [mailto:[EMAIL PROTECTED]
> Sent: 21 July 2004 13:51
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Problem of a beginner with Array[Scanned]
>
>
> Hello Torsten,
>
> > try this:
> >
> > input name="Grid1[1]" type"checkbox" file://1st
> > grid, 1st checkbox
> > input name="Grid1[2]" type"checkbox" file://1st
> > grid, 2nd checkbox...
> Seems I can't do another way than this. Not possible
> to do just Grid1[].
>
> > After submit you will receive $_POST['Grid1'] as an
> > ARRAY containing all
> > indices of the checked checkboxes. Then loop through
> > it and do what ever you
> > want:
> >
> > foreach ($_POST['Grid1'] as $value) {
> >
> > echo $value;
> > }
> So, I did it like you said but the result of echo
> $value is "on" not the checkedbox number.
>
> Regards.
>
> Dave
>
>
>
>
>
>
> Cr�ez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
> Cr�ez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
>
> Yahoo! Messenger: dialoguez instantan�ment avec vos amis.
> T�l�chargez GRATUITEMENT sur http://fr.messenger.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
The information contained in this email (and in any attachments sent with it) is
confidential. It is intended for the addressee only. Access to this email by anyone
else is unintended and unauthorized.
If you are not the original addressee, 3tc asks you to please maintain
confidentiality. If you have received this email in error please notify 3tc
immediately by replying to it, then destroy any copies and delete it from your
computer system.
Any use, dissemination, forwarding, printing or copying of this email by anyone except
the addressee in the normal course of his/her business, is strictly prohibited. 3tc
owns the copyright in this email and any document created by us and assert the right
to be identified as the author of it. Copyright has not been transferred to the
addressee.
We protect our systems with Sophos Anti-virus -
www.sophos.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php