Re: [PHP] Another problem with grids and checkboxes

2004-08-03 Thread Henri Marc
Hello,

  td style=vertical-align: top;1input
  name=grid[1][1] value=1 type=checkboxbr
/td
 [snip]
  td style=vertical-align: top;1input
  name=grid[2][1] value=1 type=checkboxbr
/td
 
 Is there a reason you're sending a 1, 2 or 3 value
 with the checkboxes? 
Well, I thought it was the good way to do.
It helps me to know which box has been checked (?).

Yes, because 
 You already know what was checked by the keys of the
 $grid array. I'd 
Yes, ok.

 td style=vertical-align: top;1input
 name=grid[1][1] value=1 
 type=checkbox?php if(isset($grid[1][1])){echo '
 checked';}?br/td
I let the value as it was because I would need to
rename a few hundreds checkboxes :-/ but I had used
your test in PHP if (isset($grid... and it works fine.
In fact it was very simple. When I think the time I
tried to find a solution. Shame on me.
Ok, my excuse is that I'm just learning.

Thank you very much.






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



[PHP] Another problem with grids and checkboxes

2004-07-31 Thread Henri Marc
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;1input
name=grid[1][1] value=1 type=checkboxbr
  /td
td style=vertical-align: top;2input
name=grid[1][2] value=2 type=checkboxbr
  /td
/tr
tr align=centertd style=vertical-align:
top;3input name=grid[1][3] value=3
type=checkboxbr

td style=vertical-align: top;1input
name=grid[2][1] value=1 type=checkboxbr
  /td
td style=vertical-align: top;2input
name=grid[2][2] value=2 type=checkboxbr
  /td
/tr
tr align=centertd style=vertical-align:
top;3input name=grid[2][3] value=3
type=checkboxbr

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;$j3;$j++) {//number of grids
   for ($k=1;$k4;$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;1input
name=grid[1][1] value=1 ?php
if(was_selected(1))) {echo checked;}?
type=checkboxbr

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



Re: [PHP] Another problem with grids and checkboxes

2004-07-31 Thread John Holmes
Henri Marc wrote:
td style=vertical-align: top;1input
name=grid[1][1] value=1 type=checkboxbr
  /td
[snip]
td style=vertical-align: top;1input
name=grid[2][1] value=1 type=checkboxbr
  /td
Is there a reason you're sending a 1, 2 or 3 value with the checkboxes? 
You already know what was checked by the keys of the $grid array. I'd 
leave it similar to how you have it, but just pass 1 for every value 
(since you won't be needing it). You can create your grid like this:

td style=vertical-align: top;1input name=grid[1][1] value=1 
type=checkbox?php if(isset($grid[1][1])){echo ' checked';}?br/td

td style=vertical-align: top;2input name=grid[2][2] value=1 
type=checkbox?php if(isset($grid[2][2])){echo ' checked';}?br/td

etc...
That'll remember what boxes were checked when the grid is redisplayed, 
also.

--
John Holmes
php|architect - The magazine for PHP professionals - http://www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php