Reputation: 3
i cant seem to make the checkbox appear as checked if this statement turns out to be true. the array passed is working fine and everything is in palce but i dont seem to find a way where i can make the checkbox checked if the value of BSS is there
<?php if(isset($_GET['cng']) && array_search("BSS", $scharr))
{
echo "checked=''";
};
?>/>
BSS
</label>
Upvotes: 0
Views: 75
Reputation: 1306
try below code:
<label for="one">
<input type="checkbox" name="school[]" value="BSS" <?php echo isset( $_GET['cng'] ) && in_array("BSS", $scharr) ? 'checked' : ''; }; ?> />
BSS </label>
Upvotes: 1
Reputation: 34
Try this code
<input type="checkbox" <?php if(isset($_GET['cng']) && array_search("BSS", $scharr)) { echo "checked";}>
Upvotes: 0
Reputation: 2361
<input type="checkbox" <?php if(isset($_GET['cng']) && isset($scharr['BSS'])) echo "checked"?> />
Upvotes: 0