I am trying to write a function to populate a drop drown box from a database. But when i try to pass a value and put in int the <select name=$selName> it appears black in the source code.
can anyone suggest what could be wrong. I defenative pass the $selName value as i have tested it useing echo.
here is the function
function populate($db_table,$field,$selName)
{
// create connection
$connection = mysql_connect("localhost","ramsn","svetlana")
or die("Couldn't make connection.");
// select database
$db = mysql_select_db("ramsn", $connection)
or die("Couldn't select database.");
// create SQL statement
$sql = "SELECT $field FROM $db_table";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection)
or die("Couldn't execute query.");
// put data into drop-down list box
while ($row = mysql_fetch_array($sql_result))
{
$ItemName = $row["ItemName"];
$option_block .= "<OPTION value=\"$ItemName\">$ItemName</OPTION>";
}
?>
<SELECT name="<?$selName?>">
<? echo "$option_block"; ?>
</SELECT>
<?
}