Jump to content

passing multiple check box values


tet3828

Recommended Posts

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

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];
    }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.