techiefreak05 Posted February 9, 2008 Share Posted February 9, 2008 They have never been my strong suit... I have this script, that gets the amount of employees from the DB, then check ot see if the number of check boxes that are CHECKED are equal to the number of employees. Basically each employee needs to be checked.. It DOES display "Verified", but the part where it tells them to verify all employees, does not show up. Anytihng wrong? <?php $loc=$_SESSION["admin_loc"]; $sql="SELECT * FROM employees WHERE Location = '$loc' ORDER BY location DESC"; $doQuery=mysql_query($sql); $getEmpCount=mysql_num_rows($dbQuery); if($_POST["doFinal"]){ $emp=$_POST['emp']; foreach ($emp as $empCheck) { if($empCheck<$getEmpCount){ echo "<center>You must verify <b>all</b> employees before finalizing.</center>"; }else{ echo "<center>Verified.</center>"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/90223-php-and-checkboxes/ Share on other sites More sharing options...
laffin Posted February 9, 2008 Share Posted February 9, 2008 check boxes only return info if it's checked otherwise ya dun get anything from the checkbox below is a sample script to show you what i mean. <?php if($_SERVER['REQUEST_METHOD']=='POST') { if(isset($_POST['cb'])) { $cbv=$_POST['cb']; echo " Checkboxes checked =" . implode(',',$cbv) . ""; } } ?> <html> <body> <form method="POST"> <INPUT TYPE='checkbox' name='cb[]' value='0'> <INPUT TYPE='checkbox' name='cb[]' value='1'> <INPUT TYPE='checkbox' name='cb[]' value='2'> <INPUT TYPE='checkbox' name='cb[]' value='3'> <INPUT TYPE='checkbox' name='cb[]' value='4'> <INPUT type="submit"> </FORM> </body> </html> but since u need all the values that checkboxes contain. your best bet is add a hidden field with the list <INPUT TYPE='hidden' NAME='valid' VALUE='<?=implode('|',$myarrayofvalidids)?>'> than explode and compare it against te values returned by the checkboxes Quote Link to comment https://forums.phpfreaks.com/topic/90223-php-and-checkboxes/#findComment-462637 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.