multipleSelect echo selected values from PHP array

multipleSelect echo selected values from PHP array

I am developing a patient database management system. 

I have a page in which you can add a patient to the database, and submit a lot of data related to that patient.

So I have a multipleSelect which is dynamically populated (from a jquery array) depending on the option selected in another selection box. This works perfectly and I then post the selected values in the  multipleSelect to my database using PHP. The values are stored in the Database in a comma separated array.

On a separate page I have a form which echoes data from my database, displaying the values for that particular selected patient. Using a combination of PHP and jquery I want to set the correct value from the database in the first selection box. I have done this successfully. Now this value determines which Jquery array should be used to set the options for the  multipleSelect. I have also done this successfully. 

MY PROBLEM IS: I need the array values from the database (retrieved using PHP) to set which options are already selected in the  multipleSelect. So if the PHP array is arm, leg, foot - I need the options arm, leg, foot to be ticked/selected in the  multipleSelect . In this way, the user will be able to see what is already stored in the database for that patient, and then edit the  multipleSelect to update the patient's information (i.e. select different values in the  multipleSelect). 

I've been stuck on this for quite a while and any help would be GREATLY appreciated.