First, this doesn't make much sense (the assignment doesn't output anything printable):
echo '<tr>'.$id[]=$rows['id'].'';
This does the same yet it's clearer (the first line, since in a loop, will go on storing all the ids in an array):
$id[] = $rows['id'];
echo '<tr>';
UPDATE:
Anyways there's no need to store the ids in an array here, just use $row['id']
to print the user identifier in the option value (right now no value is set):
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td width="50px" align="center" class="TableFormCell"><input type="checkbox" name="option[]" value="' . $row['id'] . '"/></td>';
echo '<td width="170px" align="center" class="TableFormCell">'.$row['uname'].'</td>';
echo '</tr>';
}
The form action script will receive a $_POST['option']
variable containing the selected ids. An example of how it can be used:
$ids = array();
// input filtering: convert all values to integers
foreach($_POST['option'] as $id)
{
$ids[] = (int)$id;
}
if(!empty($ids)) {
// if there's at least one selected user
$sql1 = "UPDATE ninos SET power = '$power' Where id IN (" . implode(',', $ids) . ")";
// execute the query (...)
}
nuqqsa
2010-05-11 10:00:04