Displaying a php array in html drop down input
<p>I have created a series of web pages one creates users into a sql database another page looks up all of these users then needs to show them in a drop down list for another database input. 
On calling the php file and using echo to print out the array it works fine however when i put it within my html file the drop down menu simply displays "$username_array[] = "\"".$row['Username'].""\" once I believe its something to do with escaping quotes however cant figure it out any help would be greatly appreciated!!</p>

<p>This is the code held within the html file</p>

<pre><code>&lt;?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'fid';

echo "&lt;label class=\"input\" for=\"investigator\" type=\"input\"&gt;Investigator:&lt;select id=\"investigator\" name=\"investigator\"&gt;"; 

$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn)
die('Could not connect: ' . mysql_error());

mysql_select_db($db);

$username_array = array();
$sql = mysql_query("SELECT `Username` FROM `user`");
while ($row = mysql_fetch_array($sql)){
//echo $username_array[] = "\"".$row['Username']."\"";
echo "&lt;option value='null'&gt;"$username_array[] = "\"".$row['Username'].""\"&lt;/option&gt;";
}
echo "&lt;/label&gt;";

mysql_close($conn)
?&gt;
</code></pre>

<p>I want the username array to display one user after the other within a drop down list however currently just echos out the option value line without any interpretation </p>

<p>UPDATE</p>

<p>I've now changed the code to this</p>

<pre><code>&lt;?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'fid';

$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn)
die('Could not connect: ' . mysql_error());

mysql_select_db($db);

echo '&lt;select id="investigator" name="investigator"&gt;';
$resource = mysql_query("SELECT `Username` FROM `user`");
if($resource &amp;&amp; mysql_num_rows($resource)) {
    while ($row = mysql_fetch_assoc($resource)){
        echo '&lt;option value="'.$row['Username'].'"&gt;'.$row['Username'].'&lt;/option&gt;';
    }
}
echo '&lt;/select&gt;';
mysql_close($conn)
?&gt;
</code></pre>

<p>however the html outputs the script rather than a drop down list and the usernames </p>

<p>html output</p>

<p>'; $resource = mysql_query("SELECT <code>Username</code> FROM <code>user</code>"); if($resource &amp;&amp; mysql_num_rows($resource)) { while ($row = mysql_fetch_assoc($resource)){ echo ''; } } echo ''; mysql_close($conn) ?></p>

<p>any help would be appeciated I just really need to get this working as its been bugging me for days!</p>
