Re: Problem of a beginner with Array

From: Date: Tue, 20 Jul 2004 18:33:32 +0000
Subject: Re: Problem of a beginner with Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-191213@lists.php.net to get a copy of this message
Henri Marc wrote:
I want to make a lottery site (just as an exercise), so I made a page with 6 grids of 50 numbers each (check boxes). Now, I want to know which numbers have been checked by the player. I have a : "input name="Grid1" type="checkbox" for the first grid. Grid2 for the grid #2... I was thinking to get the numbers chosen by the player with $_POST['Grid1[]'] Grid1 being a table but it doesn't work. I thought I wouldn't have to declare an array. I have 50 numbers for each grid, I don't want to have to type array followed by the 50 numbers. There is not a way to do something like array(1...50). What is the solution?
Name them like this: <input type="checkbox" name="Grid[1]"> <input type="checkbox" name="Grid[2]"> etc... Then, you can use array_keys($_POST['Grid']) to get the numbers checked. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#191213) next »