<form action="test.php" method="post">
<input type="checkbox" name="area[]" value="value 1">value 1
<input type="checkbox" name="area[]" value="value 2">value 2
<input type="checkbox" name="area[]" value="value 3">value 3
<input type="checkbox" name="area[]" value="value 4">value 4
<input type="checkbox" name="area[]" value="value 5">value 5
<input type="checkbox" value="Other" name="area[]">Other<br>
<textarea rows="2" cols="50" name="comment">write here
</textarea>
<input type="submit" />
</form>
<?php
if(!empty($_POST['area'])) {
foreach($_POST['area'] as $check) {
echo $check; //echoes the value set in the HTML form for each checked checkbox.
//so, if I were to check 1, 3, and 5 it would echo value 1, value 3, value 5.
//in your case, it would echo whatever $row['Report ID'] is equivalent to.
if($check=='other'){//if the user selected other checkbox
echo$comment=$_REQUEST['comment'];
}
}
}
?>
for more you can reffer to this
Get $_POST from multiple checkboxes
how to retrive data from the sql
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT AreaName FROM Areas";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<input type='checkbox' name='area[]' value='".$row['AreaName']."'>".$row['AreaName'];
}
} else {
echo "0 results";
}
$conn->close();
?>