Re: Quick way to test series of integers

From: Date: Fri, 25 Oct 2002 14:56:21 +0000
Subject: Re: Quick way to test series of integers
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-121433@lists.php.net to get a copy of this message
"Paul Kaiser" <paukai@illinimedia.com> wrote in message news:58851.208.216.64.17.1035495310.squirrel@illinimedia.com... > I have around 50 checkboxes on an HTML form. Their "value" is "1". So, > when a user check the box, then no problem -- the value returned by the > form is "1" and I can enter that into my SQL database. > > HOWEVER... > > If the user does not check the box, I'm in trouble, because the "value" > does not default to "0", but rather <nil> I'm guessing... You can take advantage of the way PHP parses passed values... If you have two (or more) form inputs with the same name, the last value over-writes the previous one(s). ie if your script is called like myscript.php?n=0&n=1 then you get $_GET["n"] == 1 Sure, you say, but how can I make use of that? Well, if the last value weren't sent, you would still have the previous value, ie $_GET["n"] == 0 Try this: <input type=hidden name=n value=0> // this value is *always* sent <input type=checkbox name=n value=1> // this value is only sent if checked! NOTE: the order is important! The conditional input must come *after* the default!

« previous php.general (#121433) next »