morty346 morty346 - 3 years ago 113
PHP Question

How to send checkbox state through form in a table

Below form contains a table with checkboxes as a input type
when I do a var_dump of _POST the values of each check box doesn't come through

<form method="post" action="index.php?option=com_content&view=article&id=3" name="details" >
<div id="table_container">
<table class="z">
<thead>
<tr>
<th>Select</th>
<th>Last Name</th>
<th>First Name</th>
<th>Street Num</th>
<th>Street Name</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<?
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<tr>
<td style="text-align: center; vertical-align: middle;">
<input type="checkbox" name="<?echo $row['UUID'];?>">
</td>
<td><?echo $row['last_name'];?></td>
<td><?echo $row['first_name'];?></td>
<td><?echo $row['street_num'];?></td>
<td><?echo $row['street_name'];?></td>
<td><?echo $row['city'];?></td>
<td><?echo $row['state'];?></td>
<td><?echo $row['zip'];?></td>
<td><?echo $row['phone'];?></td>
</tr>
<?
}
?>
</tbody>
</table>
</div>
<input type="hidden" id="type" name="type" value="4">
<input type="submit" value="Place On Hold">
</form>

Answer Source

So I think what you want to do is this though. If I understand it correctly.

<input type="checkbox" name="UUID[]" value="<?echo $row['UUID'];?>">

Now when you post the page you will have an array called UUID in the POST with each UUID selected.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download