sunny sunny - 3 months ago 20
SQL Question

How to retrieve data from MySQL array and make checkbox checked in list

I have a form in which I display numbers of company with checkbox. User checked these company and save this in a database table. Now I want to make an update form where I want that when data retrieve from database the checkbox is already checked in list which is checked by user while entering data.

Basically i want that when user fetches his stored results from database, he should be able to see which checkbox's he ticked earlier.

Screenshot of values which is saved by user

[![enter image description here][1]][1]

List of that values which is save in


[![enter image description here][2]][2]


When you fetch the current user's select_fi previously checked boxes (e.g. 1,2,3 ) you can convert it to PHP array with $current_user_checked_boxes_ids = explode(",",$string).

And then, inside the PHP loop you have to print the checkboxes in HTMLyou can write something like:

if (in_array(
echo '<input type="checkbox" checked="checked">';
echo '<input type="checkbox">';