Hello,

I have another problem with my program. Again!

Here it is:
I have some grids. To make it simple, let's say I have
two grids like this:

<td style="vertical-align: top;">1<input
name="grid[1][1]" value="1" type="checkbox"><br>
              </td>
<td style="vertical-align: top;">2<input
name="grid[1][2]" value="2" type="checkbox"><br>
              </td>
            </tr>
<tr align="center"><td style="vertical-align:
top;">3<input name="grid[1][3]" value="3"
type="checkbox"><br>

<td style="vertical-align: top;">1<input
name="grid[2][1]" value="1" type="checkbox"><br>
              </td>
<td style="vertical-align: top;">2<input
name="grid[2][2]" value="2" type="checkbox"><br>
              </td>
            </tr>
<tr align="center"><td style="vertical-align:
top;">3<input name="grid[2][3]" value="3"
type="checkbox"><br>

Each grid has 3 numbers, 1, 2 and 3.
There is grid[1][1], grid[1][2] and grid[1][3]
There is also the second grid, grid[2][1], grid[2][2],
grid[2][3]

The checked boxes are in an array $grid.
If the user doesn't check enough boxes, the program
must print the form again with the first choices of
this user.
I made a function for this task:

function was_selected($option)   {
GLOBAL $grid;
for ($j=1;$j<3;$j++) {//number of grids
   for ($k=1;$k<4;$k++) {//number of boxes
      if (isset($grid[$j][$k])) {
      if ($grid[$j][$k]==$option)   {
return TRUE;

Then my form is something like that:
<td style="vertical-align: top;">1<input
name="grid[1][1]" value="1" <?php
if(was_selected("1"))) {echo "checked";}?>
type="checkbox"><br>

So, normally, if the user chooses the box 1 from the
first grid, the first box of the first grid should be
checked when the browser prints the form again. But in
fact, the first box of the second grid is also
checked.

The reason is certainly because the values are the
same in all the grids. But I can't change them as it's
to make a lottery with many grids.
How can I solve this problem?

Thank you so much for your help.


        

        
                
Vous manquez d’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour 
dialoguer instantanément avec vos amis. A télécharger gratuitement sur 
http://fr.messenger.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to