Hello, I have problem using array. hope you can help me - I print list of name with checkbox next to each name: $query = mysql_query("SELECT `name`,`id` FROM `list` ORDER BY id ASC"); while($index = mysql_fetch_array($query)) { $id = $index['id']; $name = stripslashes($index['name']); echo "<div style='direction: ltr;'><input type='checkbox' id='check' name='name' value='$id' onclick='setChecks(this)' / > $name </div>"; } PHP: now I want to do 2 things: 1. check if user pick exaclly 5 options 2. Do update to the record, in the DB, for each of the five option that user picked. Thanks in advance.
this might give you an idea. for thing number 1. <form method="post" action=""> test<input type="checkbox" name="name[]" value="1" /> test<input type="checkbox" name="name[]" value="2" /> test<input type="checkbox" name="name[]" value="3" /> test<input type="checkbox" name="name[]" value="4" /> test<input type="checkbox" name="name[]" value="5" /> <input type="submit" /> </form> <?php if ($_POST['name']){ if ( count($_POST['name']) == 5){ print "exactly 5 yo!\n"; } else { print count($_POST['name']); } } ?> Code (markup):