I assume your only question is how to build your javascript line that defines the array, but instead of hard-coding the array items, you want them populated from a SQL query?
If this is the case, then this is a server-side question. And that depends on the language you are using. And this would be the wrong forum.
My suggestion is to iterate your databse recordset building a string where each time you append a comma, a single tick, the value, and another single tick. At the end of the loop, simply strip off the beginning comma. (Look at the substr command or similar in your language of choice.)
Then all you do is write your string into the javascript line as you are outputting the page.