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!

@John30013, This is only for a single value selected. The user is asking for multiple values selected.

Dear All,

Stop using this rubbish select2. This is already dead. I had a lot of issues with this Select2. I’ve spent thousands of hours searching for answers to my issues but they are just being viewed because nobody knows how to help you.

I would highly recommend using this jQuery Amsify.