Display auto selected if values are saved in database PHP

Hi

I am using select2 with php. Values are saved in database. I want to show updated data from database. I am unable to show the values auto selected in select2.

Screenshot: http://prntscr.com/t928xr

Please guide me how can I display multiple selected values is select2. I am using PHP.

Thanks

Hi
Is there any update?

Hi
Please help me. I need solution for this issue, I have searched a lot, but didn’t find solution.

Using PHP isn’t particularly relevent, since you must interact with Select2 via JavaScript. Have you read the Select2 [documentation about programmatically inserting default selected values(https://select2.org/programmatic-control/add-select-clear-items#selecting-options)? Note that if you are using Select2’s AJAX feature to retrieve data from your database, you need to follow these instructions as well.

Good luck!