how to assign database values to checkboxes from the following code i am geting only one value through post
<?php $j=0; while ($value1 = mysql_fetch_row($value)) { ?> <?php echo $value1[1]; ?> <?php echo $value1[2]; ?> } ?>
<?php $Area=$_POST[expert];
echo "".$Area."
";
?>
you are required do as below -
<td> <input type='checkbox' name='expert' value='' <?php if($value1[1]!=''){ echo "checked";}; ?> > <?php echo $value1[1]; ?> </td>
here is my algorithm to your problem, just changed the values.
<?php if(isset($_POST['btnsubmit'])){ $chk = $_POST['chk']; foreach($chk as $val){ echo $val.""; } } ?> <form method='post'> <?php while($row=mysql_fetch_array($sql)){ echo "<input type='checkbox' name='chk[]' value='".$row['fields']."' /> ".$row['fields'].""; ?> <input type='submit' name='btnsubmit' value='submit' /> </form>