From: JP H. <jp...@xs...> - 2002-05-15 22:11:46
|
At 07:49 PM 5/14/2002 -0400, rl...@mi... wrote: >You can do like this: > ><FORM METHOD=POST> ><INPUT TYPE=CHECKBOX NAME=info[0]> Info 0<BR> ><INPUT TYPE=CHECKBOX NAME=info[1]> Info 1<BR> ><INPUT TYPE=CHECKBOX NAME=info[2]> Info 2<BR> ><INPUT TYPE=CHECKBOX NAME=info[10]> Info 10<BR> ></FORM> Aren't you missing the value= component? I think you need something like: <INPUT TYPE=CHECKBOX NAME=info[0] value="1"> Info 0<BR> <INPUT TYPE=CHECKBOX NAME=info[1] value="1"> Info 1<BR> <INPUT TYPE=CHECKBOX NAME=info[2] value="1"> Info 2<BR> <INPUT TYPE=CHECKBOX NAME=info[10] value="1"> Info 10<BR> Otherwise the input has nothing to assign to the NAMEd variable. Also, doesn't that have to be in a PHP section of code? I've never seen HTML handle arrays before. And this is all well and good for assigning a 1 to every box that's checked but it doesn't assign a 0 to the unchecked boxes. Not automatically anyway. I suppose if I was using radio buttons for each element I could assign the value 1 to YES and 0 to NO but that seems a poor alternative. So, it seems to me that the next step is to have a loop to see if each element of the array has been assigned a "1" and if it hasn't then assign it a "0". This would need to occur before the implode statement, right? Or is it that I just don't even need zeros and if 4 boxes were; checked, unchecked, unchecked, checked then the implode statement would generate "1:::1". Am I getting warmer? >Then, simply use: > ><?php > $infotext = implode(":", $info); > # Put $infotext into MySQL >?> > >To display the current values: ><?php > # Get $infotext from MySQL 0:1:1:0:1... > $info = explode(":", $infotext); > while (list($index, $value) = each($info)){ > $checked = $value ? 'CHECKED' : ''; > echo "<INPUT TYPE=CHECKBOX NAME=info[$index] $checked> Info >$index<BR>\n"; > } >?> Do I read this right that you suddenly changed from "1" and "0" to "CHECKED" and "<nothing>"? (This kinda goes with my question above about maybe not needing zeros.) |