Sample HTML/PHP Form:
<?php
include("config.php");
?>
<!DOCTYPE html>
<html>
<body>
<form method="post" action="" enctype="multipart/form-data">
<?php
$sql=mysqli_query($conn,"SELECT * FROM sales");
while($rs=mysqli_fetch_array($sql)){ ?>
Checkbox:<br>
<input type="checkbox" name="bike_id[]" class="names" value="<?php echo ['field_name']; ?>">
<br>
<?php } ?>
<input type="submit" name="Submit">
</form>
</body>
</html>
PHP Code:
<?php
if(isset($_POST['bike_id'])){
$invite = $_POST['bike_id'];
print_r($invite);
}
?>
Output:
Array ( [0] => 1 [1] => 2 )
<?php
include("config.php");
?>
<!DOCTYPE html>
<html>
<body>
<form method="post" action="" enctype="multipart/form-data">
<?php
$sql=mysqli_query($conn,"SELECT * FROM sales");
while($rs=mysqli_fetch_array($sql)){ ?>
Checkbox:<br>
<input type="checkbox" name="bike_id[]" class="names" value="<?php echo ['field_name']; ?>">
<br>
<?php } ?>
<input type="submit" name="Submit">
</form>
</body>
</html>
PHP Code:
<?php
if(isset($_POST['bike_id'])){
$invite = $_POST['bike_id'];
print_r($invite);
}
?>
Output:
Array ( [0] => 1 [1] => 2 )
I want Help For the Problem I am facing: https://stackoverflow.com/questions/56951285/dynamic-table-having-multiple-checkbox-missing-first-rows-checked-checkbox-val
ReplyDeleteMultiple checkbox of same name in multiple row doesn't submit checked one as value and unchecked one as Zero
zensparkenterprises@gmail.com
DeleteJust write one sub query like, whatever values is checked update as 1 and not in as 0.
Deletehttps://manikandancbe.blogspot.com/2019/07/dynamic-checkbox-with-php-and-mysql-on.html
ReplyDeleteCheck this one, let me know its helpful for you or not.