how to assign database values to checkboxes from the following code i am geting only one value through post

<form method="POST">
<?php
$j=0;
while ($value1 = mysql_fetch_row($value)) { ?>
    <table>
    <tr>
    <td>
    <input type='checkbox' name='expert'  value=' <?php echo $value1[1]; ?>' >
    <?php echo $value1[1]; ?> </td>
    <td>
    <input type='checkbox' name='intrest' value="<?php echo $value1[2]; ?>">
     <?php echo $value1[2]; ?></td>
    </tr>
   </table> 
}
?>
<input type="submit" name="submitForm" value="submit" />
</form>



<?php 
$Area=$_POST[expert];

echo "<p>".$Area."</p>";

?>

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."<br />";
}
}

?>

<form method='post'>
<?php
while($row=mysql_fetch_array($sql)){
echo "<input type='checkbox' name='chk[]' value='".$row['fields']."' /> ".$row['fields']."<br />";
?>
<input type='submit' name='btnsubmit' value='submit' />
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.