tet3828 Posted February 14, 2008 Share Posted February 14, 2008 I wrote this dummy script to practice passing multiple check box values through &_POST. However it is only passing the last value. How can I get it to pass however many values I check and not just the last? if (!isset($_POST['test'])) { echo "<form action='filetest.php' method='POST'>"; $qry = "SELECT * FROM `staff`"; $result = mysql_query($qry) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $value = $row['eID']; echo "<input type='checkbox' value=$value name='$staff[]'>"; echo "".$row['lName'].", ".$row['fName']."<br />"; } echo "<input type='submit' name='test' value='TEST'></form>"; } else { array $returned = $_POST['staff']; echo $returned; } Link to comment https://forums.phpfreaks.com/topic/91095-passing-multiple-check-box-values/ Share on other sites More sharing options...
Isityou Posted February 14, 2008 Share Posted February 14, 2008 When you iterate try this: $count = 0; while() { $count++; $staff[$count]; } I'm to lazy to rewrite everything, but you should get the big picture. EDIT: I just noticed that name="$staff[]", what is $staff[] assigned to? Link to comment https://forums.phpfreaks.com/topic/91095-passing-multiple-check-box-values/#findComment-466894 Share on other sites More sharing options...
tet3828 Posted February 14, 2008 Author Share Posted February 14, 2008 unsurpisingly no, I still don't get it. what is the while condition? should I so something like while (number of results in posted array > $count) { display results } if (!isset($_POST['test'])) { echo "<form action='filetest.php' method='POST'>"; $qry = "SELECT * FROM `staff`"; $result = mysql_query($qry) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $value = $row['eID']; echo "<input type='checkbox' value=$value name='staff[]'>"; echo "".$row['lName'].", ".$row['fName']."<br />"; } echo "<input type='submit' name='test' value='TEST'></form>"; } else { $count = 0; while(?) { $count++; $staff[$count]; } } Link to comment https://forums.phpfreaks.com/topic/91095-passing-multiple-check-box-values/#findComment-466930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.