i am not getting dropdown with this code
<p>//here str is a variable, i just trying to assign php variable to the srt variable but i am getting an error i.e:-</p>

<blockquote>
  <p>Parse error: syntax error, unexpected 'var' (T_VAR)</p>
</blockquote>

<pre><code> &lt;script&gt;
 &lt;?php 
while($rowss = mysql_fetch_array($result2, MYSQL_ASSOC)){ 
  ?&gt;  
    var str = &lt;?php echo $rowss["ingredient"];?&gt;;
    var str_array = str.split(',');
    for(var i = 0; i &lt; str_array.length; i++) {
        // Trim the excess whitespace.
        str_array[i] = str_array[i].replace(/^\s*/, "").replace(/\s*$/, "");
        // Add additional code here, such as:
        var opt = document.createElement('option');
        opt.innerHTML = str_array[i];
        opt.value = str_array[i];
        sel.appendChild(opt);
    }
}
&lt;/script&gt;
</code></pre>