Automatcially Check Checkbox Based On Database Array Php
In the 'User Setting' tab of my page, I want the user to determine which types of posts from a specific user. Here is the form:
Solution 2:
<inputtype="checkbox"name="categories[]"value="Life"id="Life"<?phpif($something) { echo"checked"; }?>>
this may vary depending of the array content here some examples
$assoc_array = [
"life" => "yes",
"food" => "no",
];
if($assoc_array['life'] == "yes"){ echo"checked"; }
$array = [
"life",
"food"
];
if (in_array("food", $array)) {
echo"checked";
}
$assoc_array_bool = [
"life" => "whatever",
"food" => "whatever"
];
if($assoc_array_bool['life']){ echo"checked"; }
// would not check the checkbox
// if you replaced $assoc_array_bool['life'] with $assoc_array_bool['sport']
Post a Comment for "Automatcially Check Checkbox Based On Database Array Php"