September 2nd, 2000, 02:06 PM
-
Hi all!
I have several checkboxes in a html form (array). In PHP perform a count:
if (!isset($checkboxes)){
$count_checkboxes="0";}
else{
$count_checkboxes=count($checkboxes);}
echo "$count_checkboxes";
none of the checboxes is checked by default in my html form. However, even when no one is selected, $count_checkboxes returns "1" in PHP
Do I have to reset $checkboxes somehow???
September 2nd, 2000, 07:09 PM
-
Maybe try changing to this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$sizeof = count($checkboxes);
for($i=0; $i < $sizeof; $i++) {
if($checkboxes[$i] != "") {
$count_checkboxes++;
}
}
echo "$count_checkboxes";
[/code]
Unlike the Perl $# function which returns zero as the size of an array with 1 indexed item, PHP returns 1 using the count($array) function and same criteria.
------------------
<UL TYPE=SQUARE>
<LI> TD Scripts
<LI> Script School
<LI>php-scripts
</UL>
September 2nd, 2000, 07:33 PM
-
thank you SO much!!!!!!!!!!! 
i suspected something like that but was not sure, could not find the info, and thus did not know how to code the script to turn around...
i know i'm over-reacting a bit, but this was annoying me for a few days so thanks again!!!!