How can I get multiple checkbox value?

I have a page in which I have no. of records now I want to add a checkbox in my page. so that I can manage to download multiple images or file at a time.
CODE:

while($row = mysqli_fetch_array($search_result)){
				$sort=='DESC' ? $sort='ASC' : $sort='DESC';
				?>
				<tr>
<td> <?php echo $row['Product_Id']?></td>
<td> <?php echo $row['Product_Name']?></td>
<td> <?php echo $row['Image']?></td>
<td class="text-center"> <a href="download.php?id=<?php echo $row['Product_Id']?>" class="btn btn-primary">Download</a></td> 

Iā€™m not clear about exactly what you want, but multiple values can be stored in an array by naming form inputs in such a way:-

<input type="checkbox" name="chkbox[]" value="1">

Or if required you can give explicit keys to the array items:-

<input type="checkbox" name="chkbox[<?= $row['Product_Id']?>]" value="1">

The resulting $_POST array will have a value called chkbox which will be a sub-array with all the checkbox values.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.