Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic checkboxes - counting how many instances

Status
Not open for further replies.

bezierstek

Programmer
Aug 30, 2007
43
FR
Hi,

I have a form that is created dynamically from database entries, and need to know how many have been checked, but am having problems getting the figure.

The checkboxlist is created using this code
Code:
<label>
          <ul>
           <?	
	   $interestsql=mysql_query("select * from interest order by interest");
       while ($interestresult =  mysql_fetch_array($interestsql)){
						?>
                <li>
                   <input name="interestgroup[]" type="checkbox" id="interestgroup[]" value="<? echo $interestresult['intpid'] ?>" />
                <? echo $interestresult['interest'];?> </li>
                 }?>
               </ul>
            </label>

and to check it one the form has been submitted I am using this:
Code:
$interestcount =count($_POST["interestgroup"]);
echo "interest count= ".$interestcount;

The form displays fine and the html that is formed by php seems ok, but I always get 0 for $interestcount.

Can anyone help?
 
Actually, forget that, my silly error.

I actually post to the first page then refresh to the second one which displays the count so nothing was passing to the second page.

Sorted now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top