954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to assign database values to checkbox php

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."


";

?>

druveen
Newbie Poster
10 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

you are required do as below -

<td>
<input type='checkbox' name='expert' value='' <?php if($value1[1]!=''){ echo "checked";}; ?> >
<?php echo $value1[1]; ?> </td>
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

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>
vaultdweller123
Posting Pro
554 posts since Sep 2009
Reputation Points: 42
Solved Threads: 75
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: