I'm checking the database and if a particular string is matched, the respective checkbox gets checked but the error is whenever a string is matched, I'm getting two checkboxes checked, one unchecked and another checked.
Here is my code:
<?php
$result = mysqli_query($sql,"SELECT * FROM grsi ");
while($row = mysqli_fetch_array($result))
{
$focus=explode(",",$row['spr']);
?>
<input type="checkbox" value=<?php echo $row['spr']; if(in_array("Cricket",$focus)) { ?> checked="checked" <?php } ?> name="focus[]" />Cricket
<?php
}
exit();
?>
while, check your database records.$row['spr']