How to store database values as comma separated?
<p>here am trying to take the set of database values as comma separated and store it in a javascript variable. I tried doing it. but i couldnt make them comma separated as the output comes all together. Please correct me where am doing mistake.</p>

<p>Notes : If the value of assignedto is empty. the staff names with flag 1 will get fetched from database. but in the script below it comes all together where i require them to be comma separated.</p>

<pre><code> if(assignedto == "")
    {
    '&lt;?php
        $val = mysql_query("select * from staff where flag='1'");
        $arr='';
        while ($row = mysql_fetch_array($val))
        {
        $arr = array($row['name']);
        $assign .= implode(',',$arr);

    ?&gt;'
    assignedto = '&lt;?php echo $assign; }?&gt;';
    }
</code></pre>
