I have the following query that brings selected values from the DB (i.e. preferences that were entered by user through around 20 checkboxes):
$brng_selected = DB::table('Cprefs')
->where('user_id', $u_id)
->get();
return view('prefCat', ['b_sel' => $brng_selected]);
In the following example the user selected a preference with an id of 11 which refers to "sports" (in qatype field):
array(1) {
[
0
]=> object(stdClass)#368 (6) {
[
"id"
]=> int(47) [
"created_at"
]=> string(19) "2019-09-27 12:29:59" [
"updated_at"
]=> string(19) "2019-09-27 12:29:59" [
"user_id"
]=> int(12) [
"qatype"
]=> int(11) [
"type"
]=> int(1)
}
}
Now I need to configure the sports checkbox below to be checked based on the above. How can this be done?
<input type="checkbox" name="catpref[]" value=11 > Sports<br>
<input type="checkbox" name="catpref[]" value=1> Politics<br>